home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 3 / csmp-digest-v3-134 < prev    next >
Text File  |  1996-02-04  |  90KB  |  2,319 lines

  1. C.S.M.P. Digest             Fri, 02 Feb 96       Volume 3 : Issue 134
  2.  
  3. Today's Topics:
  4.  
  5.         Announcing TransSkel++
  6.         AppleScript : date to string ?
  7.         Does the DriverInstall trap really exist?
  8.         Extending Finder Drag and Drop
  9.         How to set the job name when printing?
  10.         How to think about Undo
  11.         Landmass Algorithm?
  12.         Print Jobs again - naming & copy control
  13.         Problems with UPP's
  14.         Q: Do QuickDraw routines execute faster Offscreen?
  15.         SetCCursor inside a VBL task?
  16.         Using STL with pointers to objects
  17.         VBL synching (again)
  18.  
  19.  
  20.  
  21. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  22. (pottier@clipper.ens.fr).
  23.  
  24. The digest is a collection of article threads from the internet
  25. newsgroups comp.sys.mac.programmer.help, csmp.tools, csmp.misc and
  26. csmp.games. It is designed for people who read news semi-regularly and
  27. want an archive of the discussions.  If you don't know what a
  28. newsgroup is, you probably don't have access to it. Ask your systems
  29. administrator(s) for details. If you don't have access to news, you
  30. may still be able to post messages to the group by using a mail server
  31. like anon.penet.fi (mail help@anon.penet.fi for more information).
  32.  
  33. Each issue of the digest contains one or more sets of articles (called
  34. threads), with each set corresponding to a 'discussion' of a particular
  35. subject.  The articles are not edited; all articles included in this digest
  36. are in their original posted form (as received by our news server at
  37. nef.ens.fr).  Article threads are not added to the digest until the last
  38. article added to the thread is at least two weeks old (this is to ensure that
  39. the thread is dead before adding it to the digest).  Article threads that
  40. consist of only one message are generally not included in the digest.
  41.  
  42. The digest is officially distributed by two means, by email and ftp.
  43.  
  44. If you want to receive the digest by mail, send email to listserv@ens.fr
  45. with no subject and one of the following commands as body:
  46.     help                                Sends you a summary of commands
  47.     subscribe csmp-digest Your Name     Adds you to the mailing list
  48.     signoff csmp-digest                 Removes you from the list
  49. Once you have subscribed, you will automatically receive each new
  50. issue as it is created.
  51.  
  52. The official ftp info is ftp://ftp.dartmouth.edu/pub/csmp-digest.
  53. Questions related to the ftp site should be directed to
  54. scott.silver@dartmouth.edu.
  55.  
  56. -------------------------------------------------------
  57.  
  58. >From fadushin@top.cis.syr.edu (Fred Dushin)
  59. Subject: Announcing TransSkel++
  60. Date: 18 Jan 1996 04:51:30 GMT
  61. Organization: Syracuse University, CIS Dept.
  62.  
  63. Announcing...
  64.  
  65. TransSkel++
  66. A C++ Class Framework based on TransSkel
  67.  
  68.  
  69. What is TransSkel++?
  70.  
  71.    TransSkel++ is a C++ module which runs on top of TransSkel, a freely
  72.    distributed Macintosh application skeleton written in C (and
  73.    Pascal).  TransSkel++ provides an intuitive and easy-to-use
  74.    interface to TransSkel for the C++ programmer.  In addition,
  75.    TransSkel++ provides a simple class framework for developing
  76.    Macintosh applications.
  77.  
  78.  
  79. What advantages does TransSkel++ have over TransSkel?
  80.  
  81.    TransSkel++ is written in C++.  C++ programs using TransSkel
  82.    are in the awkward position of having to declare all TransSkel
  83.    callback routines as C functions.  While this is a relatively
  84.    simple hurdle to overcome, it soon becomes tiring.  TransSkel++
  85.    helps to alleviate some of this tedium.
  86.    
  87.    In addition, TransSkel++ extends the object-oriented paradigm used
  88.    in TransSkel to define a simple set of base classes corresponding to
  89.    the sorts of object users have come to expect in a Macintosh
  90.    program: menus, windows, and dialogs.  With TransSkel++, programmers
  91.    may create instances of these or subclasses of these classes which
  92.    automatically respond to events in a program (updates, mouse clicks,
  93.    etc.) by using the event-routing mechanisms in TransSkel.
  94.    TransSkel++'s use of class hierarchies means a slight reduction in
  95.    code duplication and better opportunity for modular code over that
  96.    in TransSkel projects.
  97.  
  98.  
  99. What advantages does TransSkel have over TransSkel++?
  100.  
  101.    TransSkel++ is written in C++.  Many users of C find C++ to be 
  102.    a language which spoils the simplicity of the C language.  
  103.    Classes, polymorphism, call by reference, and inheritance 
  104.    introduce subtle issues in a language which originally gained
  105.    popularity for its elegant syntax and semantics.  C++ has
  106.    (perhaps rightly) been criticized for contaminating the purity of C.
  107.  
  108.    On the other hand, C++ provides an appropriate platform
  109.    for experiment with object oriented programming for the C
  110.    programmer; users of C need not learn an entirely new syntax in
  111.    order to explore the concepts involved in object-oriented
  112.    programming.  Macintosh C programmers may therefore find TransSkel++
  113.    to provide a suitable introduction to object oriented programming on
  114.    the Macintosh.
  115.  
  116.  
  117. How can I get TransSkel++?
  118.  
  119.    TransSkel++ is available via the World Wide Web at the URL:
  120.    
  121.       http://web.syr.edu/~fadushin/TransSkel++
  122.    
  123.    The TransSkel++ package includes source code and projects
  124.    for Symantec C++ 7.0.4.  In addition, the package includes
  125.    demonstration programs and full documentation.
  126.    
  127.    TransSkel++ runs on top of TransSkel release 3.23 (without
  128.    modification).  You must first install TransSkel 3.23 before
  129.    using TransSkel++.  TransSkel 3.23 is available via the URL:
  130.    
  131.       http://www.primate.wisc.edu/software/mac/TransSkel
  132.    
  133.    Like TransSkel, TransSkel++ is free and may be used without 
  134.    restriction.
  135.    
  136.    I would be interested in hearing comments, bug reports, or 
  137.    suggestions for improvement about TransSkel++.  I may be 
  138.    reached via the internet at 
  139.  
  140.       fadushin@top.cis.syr.edu.
  141.  
  142.  
  143. /*
  144.  *   Fred Dushin
  145.  *   School of Computer and Information Science
  146.  *   2-120 CST
  147.  *   Syracuse University
  148.  *   Syracuse, NY 13244
  149.  *
  150.  *   http://web.syr.edu/~fadushin
  151.  */
  152.  
  153.  
  154. ---------------------------
  155.  
  156. >From Philippe Gachon <p_gachon@supaero.fr>
  157. Subject: AppleScript : date to string ?
  158. Date: Mon, 15 Jan 1996 13:30:24 +0100
  159. Organization: supaero
  160.  
  161. With AppleScript, how can I convert date to string ?
  162.  
  163. (In fact, I want to rename a file to the current date.)
  164.  
  165. Thank you in advance.
  166.  
  167. -- 
  168.  
  169. +----------------------------+          ___  _  _ _ _   _ ___  ___  ___
  170. | Philippe.Gachon@supaero.fr |          |__] |__| | |   | |__] |__] |_
  171. +----------------------------+          |    |  | | |__ | |    |    |__
  172.  
  173. +++++++++++++++++++++++++++
  174.  
  175. >From technic@seanet.com (Ronald N. Tjoelker)
  176. Date: Wed, 17 Jan 1996 22:12:51 -0800
  177. Organization: Seanet Online Services, Seattle WA
  178.  
  179. In article <30FA48E0.3B95@supaero.fr>, Philippe Gachon
  180. <p_gachon@supaero.fr> wrote:
  181.  
  182. > With AppleScript, how can I convert date to string ?
  183.  
  184. Try:
  185.  
  186. set myString to (current date) as string
  187.  
  188. ---------------------------
  189.  
  190. >From nagle@netcom.com (John Nagle)
  191. Subject: Does the DriverInstall trap really exist?
  192. Date: Sun, 14 Jan 1996 03:43:45 GMT
  193. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  194.  
  195.       DriverInstall is documented in IM-Devices, on page 1-83,
  196. and there's a nice technote, DV-23, about it.  But it's not
  197. in <Devices.h>.  Instead, there's a comment:
  198.  
  199.   Note: DrvrInstall() is no longer supported, becuase it never really 
  200.   worked anyways.
  201.   There will soon be a DriverInstall() which does the right thing.
  202.  
  203. There's no sign at all of DriverInstallReserveMem in the headers,
  204. although it, too, is documented in IM-Devices.
  205.  
  206. So how do you install a unit table entry for something that supports
  207. several driver names from a single driver?  Is this just an error
  208. in the headers, or is there really no DriverInstall?
  209.  
  210.                                         John Nagle
  211.  
  212.  
  213. +++++++++++++++++++++++++++
  214.  
  215. >From jumplong@aol.com (Jump Long)
  216. Date: 15 Jan 1996 10:55:44 -0500
  217. Organization: America Online, Inc. (1-800-827-6364)
  218.  
  219. John Nagle wrote:
  220. >DriverInstall is documented in IM-Devices, on page 1-83, and
  221. >there's a nice technote, DV-23, about it.  But it's not in
  222. ><Devices.h>.  Instead, there's a comment:
  223. >
  224. >  Note: DrvrInstall() is no longer supported, becuase it never
  225. >  really worked anyways.
  226. >  There will soon be a DriverInstall() which does the right
  227. >  thing.
  228. >
  229. >There's no sign at all of DriverInstallReserveMem in the
  230. >headers, although it, too, is documented in IM-Devices.
  231. >
  232. >So how do you install a unit table entry for something that
  233. >supports several driver names from a single driver?  Is this
  234. >just an error in the headers, or is there really no
  235. >DriverInstall?
  236.  
  237. Yes, DrvrInstall in ROM has a bug and shouldn't be used.
  238.  
  239. Check out Apple's RAMDisk sample. I wrote the DriverInstall replacement
  240. routine for RAMDisk that doesn't have the bug. The RAMDisk sample also has
  241. many other routines (like code to: grow the UnitTable safely, find a
  242. unused entry driver reference number, and remove a driver) you may find
  243. useful if you're writing a driver or a disk driver.
  244.  
  245. RAMDisk can be found on the Tool Chest edition of Apple's Developer CD and
  246. at:
  247.  
  248. ftp://sam.austin.apple.com/Apple.Support.Area/Developer_Services/Sample_Co
  249. de//RAMDisk_1.2/RAMDisk_1.2.sit.hqx
  250.  
  251. - Jim Luther
  252.  
  253. ---------------------------
  254.  
  255. >From peter@adi.co.nz (Peter Bromley)
  256. Subject: Extending Finder Drag and Drop
  257. Date: Tue, 16 Jan 1996 15:53:06 +1300
  258. Organization: ADInstruments
  259.  
  260. Does anyone know if the Finder can be made to allow drag files onto
  261. something other than folders or applications? It has been done by Apple -
  262. Powertalk mailbox, etc.
  263.  
  264. The reason I am asking is that an Archiving program we are working on
  265. really needs to allow Finder drag and drop onto its archive storage
  266. documents.
  267.  
  268. TIA,
  269.  
  270. (Excuse me if this is repeated)
  271. --
  272. Peter Bromley                                  (peter@adi.co.nz)
  273. ADInstruments, Dunedin, New Zealand            
  274.  
  275. +++++++++++++++++++++++++++
  276.  
  277. >From chris-b@cs.auckland.ac.nz (Chris Burns)
  278. Date: Wed, 17 Jan 1996 11:30:29 +1300
  279. Organization: HyperMedia Unit, Comp Sci, Auckland University
  280.  
  281. In article <peter-1601961553060001@adi008.adi.co.nz>, peter@adi.co.nz
  282. (Peter Bromley) wrote:
  283.  
  284. >Does anyone know if the Finder can be made to allow drag files onto
  285. >something other than folders or applications? It has been done by Apple -
  286. >Powertalk mailbox, etc.
  287. >
  288. >The reason I am asking is that an Archiving program we are working on
  289. >really needs to allow Finder drag and drop onto its archive storage
  290. >documents.
  291.  
  292. Just make your "archive storage documents" very small applications that
  293. call your "Archiving program" with the right AppleEvents...
  294.  
  295. Chris B
  296. - ---------------------------------------------------------------------
  297. NewZealand:AucklandUniversity:ComputerScience:HyperMediaUnit:ChrisBurns
  298. Internet: chris-b@cs.auckland.ac.nz
  299. Phone:    +64 9 373-7599 x5602
  300. Fax:      +64 9 373-7453                         Async, Therefore I Am.
  301. - ---------------------------------------------------------------------
  302.  
  303. ---------------------------
  304.  
  305. >From sdr@sdr.com.au (Roger Lainson)
  306. Subject: How to set the job name when printing?
  307. Date: Wed, 10 Jan 1996 00:05:26 GMT
  308. Organization: SDR
  309.  
  310. Does anyone know how to control the name of the print job created by
  311. PrOpen(), as seen in the Print Monitor?
  312.  
  313. I'm doing a lot of printing from my own XCMD in HyperCard, and at present
  314. every job simply takes the name of the stack (or "Message" if the XCMD is
  315. invoked from HC's message box). I'd like to be able to generate my own job
  316. names. Any suggestions, please?
  317.  
  318. Roger Lainson.
  319.  
  320. - -----------------------SDR Clinical Technology------------------------
  321.           213 Eastern Valley Way, Middle Cove, NSW 2068, Australia
  322. Voice: +61-2-9958-2688     Fax: +61-2-9958-2655    email: sdr@sdr.com.au
  323.            World Wide Web: http://www.sdr.com.au/sdr/index.html
  324. - ----------------------------------------------------------------------
  325.  
  326. +++++++++++++++++++++++++++
  327.  
  328. >From gregb@genmagic.com (Greg Branche)
  329. Date: Tue, 09 Jan 1996 17:36:20 -0800
  330. Organization: General Magic
  331.  
  332. In article <sdr-1001961105260001@gateway.sdr.com.au>, sdr@sdr.com.au
  333. (Roger Lainson) wrote:
  334.  
  335. >Does anyone know how to control the name of the print job created by
  336. >PrOpen(), as seen in the Print Monitor?
  337. >
  338. >I'm doing a lot of printing from my own XCMD in HyperCard, and at present
  339. >every job simply takes the name of the stack (or "Message" if the XCMD is
  340. >invoked from HC's message box). I'd like to be able to generate my own job
  341. >names. Any suggestions, please?
  342. >
  343.  
  344. The MPW Print tool has the same problem with LaserWriter 8 drivers.  The
  345. problem does not exist with earlier drivers.
  346.  
  347. I think the problem is that the driver assumes that the object being
  348. printed is the frontmost window, and so it looks through the window list
  349. to determine the title of the window to use as the name of the print job. 
  350. I wrote this up in Apple's bug tracking system a couple of years ago, long
  351. before I lost access to the database.
  352.  
  353. Greg Branche
  354. Magic Cap Entomologist
  355. General Magic, Inc.
  356.  
  357. +++++++++++++++++++++++++++
  358.  
  359. >From jjohnson@crl.com (Jeffrey Johnson)
  360. Date: 10 Jan 1996 01:51:01 GMT
  361. Organization: CRL Dialup Internet Access        (415) 705-6060  [Login: guest]
  362.  
  363. Roger Lainson (sdr@sdr.com.au) wrote:
  364. : Does anyone know how to control the name of the print job created by
  365. : PrOpen(), as seen in the Print Monitor?
  366. : I'm doing a lot of printing from my own XCMD in HyperCard, and at present
  367. : every job simply takes the name of the stack (or "Message" if the XCMD is
  368. : invoked from HC's message box). I'd like to be able to generate my own job
  369. : names. Any suggestions, please?
  370.  
  371. I believe that PrintMonitor takes the title of the frontmost window as its
  372. job title (it's been a while). Try opening a dummy documentProc window at 
  373. coordinates outside the screen before you start the job and then kill it 
  374. when the job is done...
  375.  
  376. Thanks
  377. Jeff
  378. __
  379. Jeffrey Johnson                                               jjohnson@crl.com
  380. If you believe what you read, the sky is thick with aliens who are designing
  381. pyramids, disemboweling livestock, impregnating rural people and generally
  382. having a good time at our expense.  -Scott Adams
  383.  
  384. +++++++++++++++++++++++++++
  385.  
  386. >From Carl R. Osterwald <carl_osterwald@nrel.gov>
  387. Date: 10 Jan 1996 16:48:03 GMT
  388. Organization: National Renewable Energy Laboratory
  389.  
  390. In article <4cv625$3mu@nntp.crl.com> Jeffrey Johnson, jjohnson@crl.com
  391. writes:
  392.  
  393. >Roger Lainson (sdr@sdr.com.au) wrote:
  394. >: Does anyone know how to control the name of the print job created by
  395. >: PrOpen(), as seen in the Print Monitor?
  396.  
  397. >: I'm doing a lot of printing from my own XCMD in HyperCard, and at present
  398. >: every job simply takes the name of the stack (or "Message" if the XCMD is
  399. >: invoked from HC's message box). I'd like to be able to generate my own job
  400. >: names. Any suggestions, please?
  401.  
  402. >I believe that PrintMonitor takes the title of the frontmost window as its
  403. >job title (it's been a while). Try opening a dummy documentProc window at 
  404. >coordinates outside the screen before you start the job and then kill it 
  405. >when the job is done...
  406.  
  407. This has to be done carefully to avoid any unsightly highlighting/
  408. dehighlighting of other windows.  Also, if you have a floating window
  409. that is always on top, you can just change its title to the title of the
  410. window being printed (assuming that its title is never visible, i.e. it
  411. is a windoid).
  412.  
  413. +++++++++++++++++++++++++++
  414.  
  415. >From skevill@tartarus.uwa.edu.au (Scott Kevill)
  416. Date: Thu, 11 Jan 1996 01:46:54 +0800
  417. Organization: The University of Western Australia
  418.  
  419. In article <sdr-1001961105260001@gateway.sdr.com.au>, sdr@sdr.com.au
  420. (Roger Lainson) wrote:
  421.  
  422. : Does anyone know how to control the name of the print job created by
  423. : PrOpen(), as seen in the Print Monitor?
  424. : I'm doing a lot of printing from my own XCMD in HyperCard, and at present
  425. : every job simply takes the name of the stack (or "Message" if the XCMD is
  426. : invoked from HC's message box). I'd like to be able to generate my own job
  427. : names. Any suggestions, please?
  428. : Roger Lainson.
  429. : -------------------------SDR Clinical Technology------------------------
  430. :           213 Eastern Valley Way, Middle Cove, NSW 2068, Australia
  431. : Voice: +61-2-9958-2688     Fax: +61-2-9958-2655    email: sdr@sdr.com.au
  432. :            World Wide Web: http://www.sdr.com.au/sdr/index.html
  433. : ------------------------------------------------------------------------
  434.  
  435. Hmm.. I seem to remember it takes the name of the frontmost window, so try
  436. creating a window offscreen with the name you desire and remove it after
  437. printing.
  438.  
  439. Hope this helps,
  440.  
  441. Scott Kevill.
  442. skevill@tartarus.uwa.edu.au
  443.  
  444. +++++++++++++++++++++++++++
  445.  
  446. >From reed@medicine.wustl.edu (Thomas Reed)
  447. Date: Thu, 11 Jan 1996 12:30:52 -0600
  448. Organization: Washington University
  449.  
  450. In article <sdr-1001961105260001@gateway.sdr.com.au>, sdr@sdr.com.au
  451. (Roger Lainson) wrote:
  452.  
  453. >Does anyone know how to control the name of the print job created by
  454. >PrOpen(), as seen in the Print Monitor?
  455.  
  456. The job name is obtained from the frontmost window.  You should be able to
  457. just create something like a print status window before initiating the
  458. print job, and name this new window whatever you want the job named.  Of
  459. course, someone else did bring up a good point about floaters.  Dunno how
  460. they'll be handled...
  461.  
  462. -Thomas
  463.  
  464. =====================================================
  465. Thomas Reed                     Washington University
  466. reed@visar.wustl.edu               Medical School
  467. reed@medicine.wustl.edu            Saint Louis, MO
  468. http://medinfo.wustl.edu/~reed
  469. - ---------------------------------------------------
  470. Clothes make the man.  Naked people have little or no
  471. influence on society.  -- Mark Twain
  472. =====================================================
  473.  
  474. Opinions posted are not the opinions of Wash. U.
  475.  
  476. +++++++++++++++++++++++++++
  477.  
  478. >From mouser@zercom.net (Martin-Gilles Lavoie)
  479. Date: Thu, 11 Jan 1996 11:04:27 -0500
  480. Organization: Groupimage, inc.
  481.  
  482. In article <sdr-1001961105260001@gateway.sdr.com.au>, sdr@sdr.com.au
  483. (Roger Lainson) wrote:
  484.  
  485. > Does anyone know how to control the name of the print job created by
  486. > PrOpen(), as seen in the Print Monitor?
  487. > I'm doing a lot of printing from my own XCMD in HyperCard, and at present
  488. > every job simply takes the name of the stack (or "Message" if the XCMD is
  489. > invoked from HC's message box). I'd like to be able to generate my own job
  490. > names. Any suggestions, please?
  491. > Roger Lainson.
  492.  
  493. The printing Manager's default behaviour is to use the front window's
  494. title as the job name.
  495.  
  496. One way to change this behaviour is to create a "status dialog" while you
  497. print (wich say, for example, "printing page X of Y").  If this window is
  498. grought up before PrOpen(), the Printing Manager will use that window's
  499. title as job name.  So, you can override the job name by changing your
  500. dialog title before printing.  Many apps do this.
  501.  
  502. MGL
  503.  
  504. +++++++++++++++++++++++++++
  505.  
  506. >From McMath_C@mediasoft.net (Chuck E's In Love... McMath)
  507. Date: Mon, 15 Jan 1996 09:14:01 -0500
  508. Organization: Reed Technology & Information Services, Inc.
  509.  
  510. In article <sdr-1001961105260001@gateway.sdr.com.au>, sdr@sdr.com.au
  511. (Roger Lainson) wrote:
  512.  
  513. > Does anyone know how to control the name of the print job created by
  514. > PrOpen(), as seen in the Print Monitor?
  515. > I'm doing a lot of printing from my own XCMD in HyperCard, and at present
  516. > every job simply takes the name of the stack (or "Message" if the XCMD is
  517. > invoked from HC's message box). I'd like to be able to generate my own job
  518. > names. Any suggestions, please?
  519.  
  520. I thought I read somewhere that the print manager picks up the name of the
  521. front document as the job.  That's why if you put up one of those 'press
  522. command-period to cancel dialogs you get something like 'Untitled'.
  523.  
  524. The suggestion for having your own job names was to create a small window
  525. off-screen; give this window the name that you want to appear in the print
  526. manager window.  I believe I've done this and it works.
  527.  
  528. Hope this helps,
  529.  
  530. chuck
  531.  
  532. |-- Chuck McMath -- McMath_C@mediasoft.net -or-- chuck@ocs.com -----|
  533. |-- Reed Technology & Information Services, Inc. -------------------|
  534. |-- 20251 Century Blvd. -- Germantown, MD  20874 -------------------|
  535. |-------------- "Hey Batter, Hey Batter, swing!" - Anon.------------|
  536. |--------------- My Karma Ran Over My Dogma ------------------------|
  537.  
  538.  
  539. ---------------------------
  540.  
  541. >From kurisuto@babel.ling.upenn.edu (Sean Crist)
  542. Subject: How to think about Undo
  543. Date: 10 Jan 1996 03:52:56 GMT
  544. Organization: University of Pennsylvania
  545.  
  546. How do you implement the Undo command?  This is such a broad question, and
  547. once whose specific answer will vary so much depending on the particular
  548. application, that I'm not even sure how meaningful it is to ask it.  But
  549. I'm interested in finding some coherent way to think about the problem.
  550.  
  551. By way of example, suppose I'm writing a simple object-oriented graphics
  552. application (like MacDraw).  Suppose there are four graphic objects, each
  553. with a different fill pattern; the user selects all four and changes their
  554. pattern to something else.  To Undo this, I somehow have to remember the
  555. four original patterns of the selected objects.  I can think of at least
  556. two paradigms for thinking about Undo here:
  557.  
  558. Paradigm 1: Whatever the data structure is in which I store these objects
  559. (an array, say), I keep two whole structures: the version before the
  560. change, and the version after the change.  I implement Undo/Redo by
  561. swapping these back and forth.  This roughly doubles the amount of memory
  562. needed for the data, but is relatively simple to code.
  563.  
  564. Paradigm 2: I keep only one copy of the data structure, but I make a list
  565. of operations which have to be performed to Do/Redo and Undo the action, in
  566. some unseen, application-internal format.  For example, when the user
  567. changes the pattern of the four selected items, this translates into a
  568. Do/Redo list which in English means something like the following:
  569.  
  570. Change the pattern of object 1 to pattern 5
  571. Change the pattern of object 2 to pattern 5
  572. Change the pattern of object 3 to pattern 5
  573. Change the pattern of object 4 to pattern 5
  574.  
  575. At the time the user performs the command, I also compose a list of Undo
  576. operations, i.e. operations which have to be done to put things back in
  577. their previous state:
  578.  
  579. Change the pattern of object 1 to pattern 2
  580. Change the pattern of object 2 to pattern 17
  581. Change the pattern of object 3 to pattern 3
  582. Change the pattern of object 4 to pattern 10
  583.  
  584. To Undo/Redo, I alterately execute these two lists of operations.  This
  585. paradigm requires less memory for data, but it requires an extra level of
  586. representation between the user interface and the data, which could add
  587. greatly to the coding complexity.
  588.  
  589. Thoughts?  I have many more questions and ideas, but do either of these
  590. approaches seem to be on the right track?  And is it normal to feel that
  591. this one dinky command alone is half the work of coding an application?
  592.  
  593.   \/ __ __    _\_     --Sean Crist  (kurisuto@unagi.cis.upenn.edu)
  594.  ---  |  |    \ /     For a free copy of the Bill of Rights, finger
  595.   _| ,| ,|   -----    this account.  It's also available through
  596.   _| ,| ,|    [_]     my homepage:
  597.    |  |  |    [_]     http://babel.ling.upenn.edu/~kurisuto/homepage.html
  598.  
  599.  
  600.  
  601.  
  602.  
  603. +++++++++++++++++++++++++++
  604.  
  605. >From kenlong@netcom.com (Ken Long)
  606. Date: Wed, 10 Jan 1996 08:11:43 GMT
  607. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  608.  
  609. Color It! has 15 levels of undo.  Gunshy has as many levels of undo as it 
  610. has "do".
  611.  
  612. Color It! still has redo for the last one, but you can, "Undo, Redo, 
  613. Undo" and still continue to undo as many levels back as it goes.  How 
  614. does it do it?  Temporary files.
  615.  
  616. Gunshy probably uses an array, but it can only go so far because it only 
  617. has so many icons.
  618.  
  619. So, in Color It!, you're probably looking at a queue - like the queue in 
  620. Moire or ZoomIdle or some such (Electric Fire AD mod.).  if (numTemp > 15)
  621. remove (firstFile);..., or some such.  If you don't have enough disk 
  622. space, you get an alert saying the "undo buffer" could not be created.  
  623. But the "buffer" would consist of whatever RAM based tracking of the temp 
  624. files, plus a multiplier of space comparable to the file size of the file 
  625. being worked on, for the temp files.
  626.  
  627. I'd bet the temp files were not as big as the original, but contained a 
  628. portion which dealt with the "done" part.  No matter how many actions 
  629. were done - even if over 15 - there would still need to be retained the 
  630. original for "revert to saved" to happen.
  631.  
  632. Those are mt "ideas" on it.
  633.  
  634. -Ken-
  635.  
  636. +++++++++++++++++++++++++++
  637.  
  638. >From pottier@drakkar.ens.fr (Francois Pottier)
  639. Date: 10 Jan 1996 13:31:19 GMT
  640. Organization: Ecole Normale Superieure, Paris
  641.  
  642. In article <4cvd6o$24d@netnews.upenn.edu>,
  643. Sean Crist <kurisuto@babel.ling.upenn.edu> wrote:
  644.  
  645. >Paradigm 2: I keep only one copy of the data structure, but I make a list
  646. >of operations which have to be performed to Do/Redo and Undo the action, in
  647.  
  648. This has the advantage that it takes relatively little memory, so you
  649. can actually have many levels of Undo using this method, while it
  650. would probably be impractical using the other method.
  651.  
  652. >some unseen, application-internal format.
  653.  
  654. If your application is scriptable, the natural format to use for these
  655. commands would probably be Apple events. I think you should have a look
  656. at the code in PowerPlant (and possibly other frameworks) which has code
  657. to handle Undo/Redo.
  658.  
  659. > And is it normal to feel that this one dinky command alone is half
  660. > the work of coding an application?
  661.  
  662. Sure. This is why most applications leave it out - only serious, real
  663. ones implement it.
  664.  
  665. -- 
  666. Francois
  667. pottier@dmi.ens.fr
  668. http://www.eleves.ens.fr:8080/home/pottier/
  669.  
  670. +++++++++++++++++++++++++++
  671.  
  672. >From DaveZ@mailbag.com (David B. Zwiefelhofer)
  673. Date: Wed, 10 Jan 1996 10:10:11 -0500
  674. Organization: Utility Reduction Specialists, Inc.
  675.  
  676. In article <4d0f37$ifs@nef.ens.fr>, pottier@drakkar.ens.fr (Francois
  677. Pottier) wrote:
  678.  
  679. [snip]
  680. > Sure. This is why most applications leave it out - only serious, real
  681. > ones implement it.
  682.  
  683. Yeah, I guess that's kind of true. I recently added undo for text input in
  684. the dialogs of a utility I'm working on. I wanted to get a feel for
  685. precisely how undo should behave. Of course, I went to an Apple app to
  686. check it out, SimpleText, and lo and behold, no undo!
  687.  
  688. -Dave
  689.  
  690. -- 
  691. David B. Zwiefelhofer
  692. Utility Reduction Specialists, Inc.
  693. 1605 Monroe Street, Suite 110
  694. Madison, WI  53211-2052
  695. (608) 258-8965
  696. (608) 258-9686 FAX
  697.  
  698. +++++++++++++++++++++++++++
  699.  
  700. >From rick@kagi.com (Rick Holzgrafe)
  701. Date: Thu, 11 Jan 1996 14:38:09 -0800
  702. Organization: Semicolon Software
  703.  
  704. In article <4cvd6o$24d@netnews.upenn.edu>, kurisuto@babel.ling.upenn.edu
  705. (Sean Crist) wrote:
  706.  
  707. > Paradigm 1: Whatever the data structure is in which I store these objects
  708. > (an array, say), I keep two whole structures: the version before the
  709. > change, and the version after the change.  I implement Undo/Redo by
  710. > swapping these back and forth.  This roughly doubles the amount of memory
  711. > needed for the data, but is relatively simple to code.
  712. > Paradigm 2: I keep only one copy of the data structure, but I make a list
  713. > of operations which have to be performed to Do/Redo and Undo the action, in
  714. > some unseen, application-internal format.  [...]  This
  715. > paradigm requires less memory for data, but it requires an extra level of
  716. > representation between the user interface and the data, which could add
  717. > greatly to the coding complexity.
  718.  
  719. In an object-oriented approach, for each undoable operation you would
  720. define a "command" class. The command class knows both how to execute the
  721. operation and how to undo it. It is a subclass of a generic command class:
  722. from the generic class it inherits Do and Undo methods which it overrides
  723. to do its particular work, and it adds its own specific and appropriate
  724. kinds of data storage.
  725.  
  726. If you are not using an object-oriented language, you can accomplish the
  727. same effect with data structures which include function pointers to their
  728. Do and Undo routines.
  729.  
  730. There is value to this approach that goes beyond simple Undo. All of your
  731. app's operations can be accomplished by first creating an appropriate
  732. command object (or struct, record, whatever) and then calling its Do
  733. routine. This is a nice way to separate the user interface from the
  734. working guts of the program: all a control does is create a command and
  735. then tell it to Do. It becomes simple to add alternate controls, or to
  736. completely change the entire user interface. Your application becomes
  737. easily scriptable (well, more easily) since the scripting interface
  738. becomes just another set of "controls" that create and then execute
  739. command objects.  It allows easy, effective journaling -- to keep a record
  740. of the user's operations, you just keep an ordered list of all the command
  741. objects that have been created and executed. Extended or unlimited
  742. undo/redo becomes simple: just keep that same list, with a pointer to
  743. "where you are" in the list. For repeated undos, just back up the pointer
  744. and call the Undo routine. To redo, move the pointer forward and call the
  745. Redo routine. The only limit is available memory, and with careful design
  746. most command objects may be small enough to be negligible in size.
  747.  
  748. There's more to it than that, of course. It's important to have no
  749. non-undoable operations, difficult though that may be; otherwise you have
  750. to throw away the entire undo history whenever a non-undoable action is
  751. performed. If the user undoes a bunch of commands and then does something
  752. new, remember to throw away everything in the list from the most recently
  753. undone command forward. (Or you could make a branching tree structure, but
  754. I have no idea how you'd make that comprehensible to the user.) Sometimes
  755. what feels like a single operation to the user is really a sequence of
  756. internal command; then you need a way to group command objects so they can
  757. be undone and redone as a batch, to preserve the user's feeling that the
  758. operation was atomic.
  759.  
  760. >And is it normal to feel that
  761. > this one dinky command alone is half the work of coding an application?
  762.  
  763. Well, yes. It's not a "dinky command"; it is (or should be) rooted deeply
  764. in the architecture of your application. Coding up all those subclasses of
  765. the command class is indeed tedious, but it really pays off.
  766.  
  767. -- Rick Holzgrafe
  768.    Semicolon Software
  769.    rick@kagi.com
  770.    http://www.opendoor.com/Rick/Semicolon.html
  771.  
  772. +++++++++++++++++++++++++++
  773.  
  774. >From snozer@cats.ucsc.edu (Daniel Craig Jalkut)
  775. Date: 19 Jan 1996 20:57:56 GMT
  776. Organization: University of California, Santa Cruz
  777.  
  778.  
  779. In <4dlv8k$ff1@newsbf02.news.aol.com> mrmikeyh@aol.com (MrMikeyH) writes:
  780.  
  781. >It's these really difficult to implement features that make Macs  so
  782. >wonderful to use.  Things like point and click, pasting from one
  783. >application to another.  These all require a tremendous amount of work.
  784. >But I could not imagine working without Undo.  It would be a blaspheme to
  785. >ask my end users to work without it.
  786. >Mike
  787.  
  788. Do they require a trememdous amount of work?
  789.  
  790. "point and click" -- is handled very simply by the Macintosh event handler.  
  791. The application has the easiest time, merely asking "what happened" and 
  792. basically having the toolbox nudge Application towards the correct response
  793. code.
  794.  
  795. "pasting from one application to another" -- is incredibly easy to implement
  796. thanks to the Scrap manager in, you guessed it, the toolbox. 
  797.  
  798. "undo" -- is extremely simple with one-step undo, where you are only ever 
  799. allowed to revert to the state of the program before the last action.  If 
  800. you add a stack structure, you can easily provide "infinite" undo, which 
  801. is a lot more exciting than undo and also checks in at relatively "simple" 
  802. as far as coding.
  803.  
  804. -- 
  805. _______
  806. Daniel Craig Jalkut     "All I know is that I don't know nothing,
  807. snozer@cats.ucsc.edu    and that's FINE" -- Operation Ivy
  808. Macintosh enthusiast, BeBox independent developer in waiting.
  809.  
  810. ---------------------------
  811.  
  812. >From pmiller@mmm.com (Phil Miller)
  813. Subject: Landmass Algorithm?
  814. Date: Wed, 10 Jan 1996 12:20:45 -0600
  815. Organization: 3M
  816.  
  817. I'm writing a game which will need to create a random
  818. world map -- areas of landmass surrounded by water.  I've
  819. tried a couple of algorithms to generate the land with
  820. limited success.
  821.  
  822. I'm representing the world map as a two dimensional array
  823. which I initialize to all zeros.
  824.  
  825. The best algorithm to date starts with several "seeds"
  826. distributed more or less randomly in the map array.  Then
  827. I recursively examine the array and if I see a non-zero value,
  828. I use some logic to decide whether or not to make the
  829. neighbors around that element non-zero as well.
  830.  
  831. This algorithm tends to make land masses that look more
  832. like spots of mold in a petri dish rather than things that
  833. look like continents.  I can change the shape of the
  834. "mold colonies" by altering the logic in the algorithm,
  835. but I still don't get things that look like continents.
  836.  
  837. I've toyed with some other ideas to try to mimic how
  838. real continents are formed such as:
  839.  
  840. 1)  Creating some imaginary "fault lines" throughout
  841. the world and seeding continents on those lines to mimic
  842. real continent placement
  843.  
  844. or
  845.  
  846. 2)  Creating random landmasses and moving them around
  847. randomly as if they're riding on tectonic plates.  Places
  848. of collision become mountain ranges, etc.
  849.  
  850.  
  851. I haven't written any code to see how these ideas will
  852. work out yet.  Does anybody have any bright ideas that I
  853. could try?
  854.  
  855. Thanks
  856.  
  857. Phil Miller
  858. pmiller@mmm.com
  859.  
  860. Opinions expressed herein are my own and may not represent those of 3M.
  861.  
  862. +++++++++++++++++++++++++++
  863.  
  864. >From dangit@netcom.com (Lam Dang)
  865. Date: Thu, 11 Jan 1996 00:31:33 GMT
  866. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  867.  
  868. Phil Miller (pmiller@mmm.com) wrote:
  869. : I'm writing a game which will need to create a random
  870. : world map -- areas of landmass surrounded by water.  I've
  871.  
  872. Ok, the following is a typical fractal land generator, but I don't
  873. quite remember any references to text, so...
  874.  
  875. This is going to be a recursive type deal.  Ok, so you have an 2D
  876. array of dimensions WIDTH and HEIGHT, with values from 0 to MAXVAL.
  877. You start off by putting random values in the four corners.  In the
  878. middle of the rectangle, you put the average of the corner values.
  879. Do the exact same thing for the four new rectangles you create.
  880. (i.e., topleft, topright, bottomleft, bottomright).  You stop
  881. recursing when the middle pixel you are filling in is the same as the
  882. 'corner' pixel.
  883.  
  884. This creates a nice looking texture.  You can arbitrarily set the
  885. water 'depth', to see how it looks.  Playing with the inital four
  886. corner values dramatically alters the result.  Also, instead of a 
  887. straight average, you can do an average (+/-) value, or whatnot.
  888.  
  889. However, i think that this tends not to make planet-like maps; it looks more
  890. like river beds, etc.  Problem is that continents are shaped thru magma 
  891. flows, etc...  You could start by creating random polygons, that follow a 
  892. certain 'continent' rule, then do a similar algorithm, but with polygons, 
  893. instead of rects... could get complicated tho!
  894.  
  895. -jD
  896. -- 
  897. Lam Dang
  898. dangit@netcom.com
  899.  
  900.                                 
  901.  
  902. +++++++++++++++++++++++++++
  903.  
  904. >From Kyle Dean <kaschei@cs.su.oz.au>
  905. Date: Thu, 11 Jan 1996 16:14:15 +1100
  906. Organization: Basser Dept of Computer Science, University of Sydney, Australia
  907.  
  908. One method I've seen and used to create good looking terrain is through
  909. fractals and recursive algorithms.
  910.  
  911. The basic idea is to roughly generate some terrain, and then fill in the
  912. bits.
  913.  
  914. So you start with your two dimensional array, initialised to zeros,
  915. which here will represent the altitude of the land of your world.
  916.  
  917. Then you call a recursive procedure to fill it in, which takes the map,
  918. and the co-ordinates of the rectangle to be filled in.
  919.  
  920. If the rectangle is "too small" (ie zero or one units wide or tall),
  921. then no work has to be done, and you're finished.
  922.  
  923. Otherwise, find the co-ordinates of the mid-points of each side. Set the
  924. altitude of the mid-point of each side to be the average of the
  925. altitudes of the end-points of that side PLUS (this is the trick!) a
  926. random numer TIMES the length of that side. Do a similar thing with the
  927. centre of the rectangle (ie average of corners + random proportion of
  928. diagonal). Then call your recursive procedure with each of the four
  929. smaller rectangles.
  930.  
  931. When the first call to the recursive procedure returns, the world will
  932. be generated, complete down to the fiddly bits. It looks like a mountain
  933. range - just pick a sealevel and get islands/continents. If your random
  934. numbers range evenly from +/- N, then you can use zero as sealevel.
  935. Negative altitudes are water, postive land. (zero is prime beachfront!)
  936.  
  937.  
  938. typedef int **WorldMap;
  939.  
  940. void GenerateWorld(WorldMap map, Rect r)
  941. {
  942.         int  width = (r.right - r.left);
  943.         int  height = (r.bottom - r.top);
  944.         int  midH = (r.left + r.right) / 2;     // middle x co-ord
  945.         int  midV = (r.top + r.bottom) / 2;     // middle y co-ord
  946.         Rect closer;                            // next recursion
  947.  
  948.         if ( (width < 2) || (height < 2))       // too small
  949.                 return;
  950.  
  951.         map[midH][r.top] = 
  952.                 ( map[r.right][r.top] + map[r.left][r.top]) / 2
  953.                 + Random() * width;
  954.  
  955.         // ... etc. for other three mid-points, and the centre
  956.  
  957.         closer.left = r.left;
  958.         closer.top = r.top;
  959.         closer.right = mid.H;
  960.         closer.bottom = midV;
  961.         GenerateWorld(map, closer);  // recurse: generate top left quad
  962.  
  963.         // ... etc. for other three quadrants
  964. }
  965.  
  966.  
  967. Kyle.
  968.  
  969. Izvinite, ya speshu na avtobus.
  970.  
  971. +++++++++++++++++++++++++++
  972.  
  973. >From songer@lexmark.com
  974. Date: Thu, 11 Jan 1996 18:21:15 GMT
  975. Organization: Lexmark International, Lexington, KY
  976.  
  977. In article <pmiller-1001961220450001@pm37697.mmm.com> pmiller@mmm.com (Phil Miller) writes:
  978.    [...]
  979.    I'm writing a game which will need to create a random
  980.    world map -- areas of landmass surrounded by water.  I've
  981.    tried a couple of algorithms to generate the land with
  982.    limited success.
  983.    [...]
  984.  
  985. Hi!
  986.  
  987.      There was a big discussion of this problem on
  988. rec.games.programmer some time ago. (May be years ago -- I cannot
  989. recall.) It may be worthwhile to go back and check USENET archives to
  990. take a look for it.
  991.  
  992. Anyway,
  993. -Chris
  994.  
  995. +++++++++++++++++++++++++++
  996.  
  997. >From shebs@cygnus.com (Stan Shebs)
  998. Date: 11 Jan 1996 11:53:27 -0800
  999. Organization: Cygnus Support
  1000.  
  1001. In article <30F49CA7.2EC8@cs.su.oz.au> Kyle Dean <kaschei@cs.su.oz.au> writes:
  1002.  
  1003.    [...]
  1004.  
  1005.    Otherwise, find the co-ordinates of the mid-points of each side. Set the
  1006.    altitude of the mid-point of each side to be the average of the
  1007.    altitudes of the end-points of that side PLUS (this is the trick!) a
  1008.    random numer TIMES the length of that side. Do a similar thing with the
  1009.    centre of the rectangle (ie average of corners + random proportion of
  1010.    diagonal). Then call your recursive procedure with each of the four
  1011.    smaller rectangles.
  1012.  
  1013. This algorithm is known to have a serious intrinsic flaw; the
  1014. resulting map will very often have horizontal and vertical lines at
  1015. the subdivision points.  This can be deadly for an exploration game,
  1016. since the savvy player will immediately cruise to the midpoints and
  1017. then know whether the terrain will be high or low around them, without
  1018. actually having to explore.  Even for a non-exploration games, the
  1019. shapes will have lots of vertical and horizontal mountain ranges, but
  1020. very rarely a diagonal one (you can see this in many commercial games
  1021. once you know what to look for).
  1022.  
  1023. Tricks such as picking random locations along each side instead of the
  1024. midpoint don't help much, since the problem is fundamental to the
  1025. recursive algorithm.  Several years ago, I spent a couple months
  1026. trying to fix this algorithm, with no success, and finally switched to
  1027. a true fractal algorithm, which just means randomly placing lots of
  1028. randomly-sized blobs, some of which raise the elevation, and some of
  1029. which lower it.  Results were much less predictable and much more
  1030. "natural-looking".  To see a code example (which has many elaborations
  1031. on the basic algorithm, such as user control over the percentages of
  1032. sea/swamp/desert/forest etc), look at the file kernel/mkterr.c in the
  1033. sources to my game Xconq.  See http://www.cygnus.com/~shebs/xconq.html,
  1034. or ftp from ftp.cygnus.com, pub/xconq.
  1035.  
  1036.                                                         Stan Shebs
  1037.                                                         shebs@cygnus.com
  1038.  
  1039.  
  1040.  
  1041.  
  1042. +++++++++++++++++++++++++++
  1043.  
  1044. >From zzkbergm@dingo.uq.edu.au (Christoph Bergmann)
  1045. Date: Fri, 12 Jan 1996 14:39:06 +1000
  1046. Organization: University of Queensland
  1047.  
  1048. In article <pmiller-1001961220450001@pm37697.mmm.com>, pmiller@mmm.com
  1049. (Phil Miller) wrote:
  1050.  
  1051. > The best algorithm to date starts with several "seeds"
  1052. > distributed more or less randomly in the map array.  Then
  1053. > I recursively examine the array and if I see a non-zero value,
  1054. > I use some logic to decide whether or not to make the
  1055. > neighbors around that element non-zero as well.
  1056. > This algorithm tends to make land masses that look more
  1057. > like spots of mold in a petri dish rather than things that
  1058. > look like continents.  I can change the shape of the
  1059. > "mold colonies" by altering the logic in the algorithm,
  1060. > but I still don't get things that look like continents.
  1061.  
  1062. > 1)  Creating some imaginary "fault lines" throughout
  1063. > the world and seeding continents on those lines to mimic
  1064. > real continent placement
  1065. > or
  1066. > 2)  Creating random landmasses and moving them around
  1067. > randomly as if they're riding on tectonic plates.  Places
  1068. > of collision become mountain ranges, etc.
  1069. > I haven't written any code to see how these ideas will
  1070. > work out yet.  Does anybody have any bright ideas that I
  1071. > could try?
  1072.  
  1073. hmm. 1 sounds quite reasonable.. pick a point, make a 'squiggly line' from
  1074. the point, and seed everything from this..
  1075.  
  1076. 2 sounds like a waste of time, sure it is realistic, but it would be a
  1077. simulation and i dont think the problem calls for this. imo, it is like
  1078. simulating molecular movement to do characters in a sprite game.. (well,
  1079. not that bad but u get the idea... )
  1080.  
  1081. i'd go with something like 1.
  1082.  
  1083. maybe make a number of peaks to make mountains, then get it to decide
  1084. which ones are closest, ie. pick a random number of continents and bunch
  1085. them into this number of continents giving the least overall area/distance
  1086. between points or something along these lines.. not to hard to code, maybe
  1087. worth trying..
  1088.  
  1089. ChrisB
  1090.  
  1091. +++++++++++++++++++++++++++
  1092.  
  1093. >From rickgenter@aol.com (RickGenter)
  1094. Date: 12 Jan 1996 05:18:00 -0500
  1095. Organization: America Online, Inc. (1-800-827-6364)
  1096.  
  1097. >>>
  1098. Does anybody have any bright ideas that I
  1099. could try?
  1100. <<<
  1101.  
  1102. Have each cell in your grid represent an elevation. Populate the entire
  1103. grid, randomly raising/lowering the elevation in each cell. (You may want
  1104. to do this less randomly to implement mountain ranges, valleys, etc.)
  1105. After you're done, pick a level to be sea level, and zero out everything
  1106. below that line.
  1107.  
  1108. Hope this helps.
  1109.  
  1110. Rick Genter
  1111. Papyrus Design Group, Inc.
  1112.  
  1113. +++++++++++++++++++++++++++
  1114.  
  1115. >From thor@telerama.lm.com (Tom Moertel)
  1116. Date: 14 Jan 1996 01:59:14 -0500
  1117. Organization: Management Science Associates
  1118.  
  1119. Stan Shebs (shebs@cygnus.com) wrote:
  1120. : In article <30F49CA7.2EC8@cs.su.oz.au> Kyle Dean
  1121. : <kaschei@cs.su.oz.au> writes:
  1122.  
  1123. :    [...]
  1124.  
  1125. > > Otherwise, find the co-ordinates of the mid-points of each side.  
  1126. > > Set the altitude of the mid-point of each side to be the average 
  1127. > > of the altitudes of the end-points of that side PLUS (this is the 
  1128. > > trick!)  a random numer TIMES the length of that side.  Do a 
  1129. > > similar thing with the centre of the rectangle (ie average of 
  1130. > > corners + random proportion of diagonal).  Then call your 
  1131. > > recursive procedure with each of the four smaller rectangles.
  1132.  
  1133. > This algorithm is known to have a serious intrinsic flaw; the 
  1134. > resulting map will very often have horizontal and vertical lines 
  1135. > at the subdivision points.  [...]
  1136.  
  1137. > Tricks such as picking random locations along each side instead 
  1138. > of the midpoint don't help much, since the problem is fundamental 
  1139. > to the recursive algorithm.  Several years ago, I spent a couple 
  1140. > months trying to fix this algorithm, with no success, and finally 
  1141. > switched to a true fractal algorithm, which just means randomly 
  1142. > placing lots of randomly-sized blobs, some of which raise the 
  1143. > elevation, and some of which lower it.  Results were much less 
  1144. > predictable and much more "natural-looking".  To see a code 
  1145. > example (which has many elaborations on the basic algorithm, such 
  1146. > as user control over the percentages of sea/swamp/desert/forest 
  1147. > etc), look at the file kernel/mkterr.c in the sources to my game 
  1148. > Xconq.  See http://www.cygnus.com/~shebs/xconq.html, or ftp from 
  1149. > ftp.cygnus.com, pub/xconq.
  1150.  
  1151. You can avoid the horizontal and vertical artifacts by randomly
  1152. adjusting *all* the heights, not just the newly-added midpoints.
  1153. The recursive method works fine with this simple adjustment.  For
  1154. some examples of land generated this way, see:
  1155.  
  1156.     http://www.telerama.com/~thor/fBm/
  1157. -- 
  1158. Tom Moertel                          Interests:  Software Engineering,
  1159.                                                  Symbolic Mathematics,
  1160. MSA, Commercial Software Group                   Algorithms,
  1161. thor@telerama.lm.com                             Itchy-Scratchy Theory.
  1162.  
  1163. +++++++++++++++++++++++++++
  1164.  
  1165. >From dwgray@aol.com (DWGray)
  1166. Date: 15 Jan 1996 09:46:22 -0500
  1167. Organization: America Online, Inc. (1-800-827-6364)
  1168.  
  1169. I, too, am writing a landmass generator, and have passed through the
  1170. 'petri-dish' (a very accurate description) stage you mentioned.  What I
  1171. ended up doing was to separate the "growth" and "erosion" stages so that I
  1172. had a long period of landmass expansion, and then about 1/3 to 1/2 as long
  1173. period of landmass contraction.  The percentages I used to determine if a
  1174. particular pixel increased in height was different than the ones I used
  1175. for decrease during erosion, so that the mountains created during growth
  1176. weren't levelled.  You might try this approach.
  1177.  
  1178. For seeding, I began with single pixels, then moved on to rectangles, then
  1179. decided that seeding mountains on those rectangles generated better
  1180. mountains ranges and gave me better chances for areas of hilly country. 
  1181. The problem I then ran into was that no lakes were created.  So, I began
  1182. seeding pixels of water _during_ the erosion process.  My erosion is
  1183. pretty destructive, so I only needed single pixels to create lakes.  
  1184.  
  1185. The biggest problem I ran into with the algorithm you are currently using
  1186. is that of landmasses connected by thin bridges.  It makes very
  1187. unusual-looking continents if the initial placement of rectangles (or
  1188. circles or whatever) aren't close enough together.
  1189.  
  1190. Hope this helps,
  1191. - Don Gray
  1192.  
  1193. p.s. I am currently researching a completely different algorithm that will
  1194. give me a lot more control over placement of rivers and towns (always the
  1195. most difficult things to make look right) and other geographical features.
  1196.  It's still in development, so I can't yet say whether it's worthwhile to
  1197. use.
  1198.  
  1199.  
  1200. ---------------------------
  1201.  
  1202. >From sdr@sdr.com.au (Roger Lainson)
  1203. Subject: Print Jobs again - naming & copy control
  1204. Date: Sun, 14 Jan 1996 23:47:08 GMT
  1205. Organization: SDR
  1206.  
  1207. Thanks to everybody who helped with my query about how to name a printer
  1208. job. The concensus of the comments (plus a few experiments) is that the
  1209. job name takes the name of the frontmost window, which must be visible but
  1210. which can be offscreen. Floaters are ignored (as in FrontWindow). The name
  1211. is picked up by the call to PrJobDialog (or PrValidate if you ain't using
  1212. a dialog (tut tut)).
  1213.  
  1214. While on print jobs the following may be of interest. IM Vol II implies
  1215. that in the TPrint structure, prJob.iCopies can be used to examine the
  1216. number of copies specified in the print dialog (Think Reference says this
  1217. explicitly). My experience (with the Laserwrite 8 driver) is that
  1218. prJob.iCopies stays obstinately at 1, but prXInfo.iRowBytes *does* reflect
  1219. the number of copies (and can be used to *set* the number of copies for
  1220. that matter). 
  1221.  
  1222. Seems a bit odd to have a field documented for the purpose and then use a
  1223. different one, but presumably I shouldn't be messing with the print copies
  1224. anyway!
  1225.  
  1226. - -----------------------SDR Clinical Technology------------------------
  1227.           213 Eastern Valley Way, Middle Cove, NSW 2068, Australia
  1228. Voice: +61-2-9958-2688     Fax: +61-2-9958-2655    email: sdr@sdr.com.au
  1229.            World Wide Web: http://www.sdr.com.au/sdr/index.html
  1230. - ----------------------------------------------------------------------
  1231.  
  1232. +++++++++++++++++++++++++++
  1233.  
  1234. >From dowdy@apple.com (Tom Dowdy)
  1235. Date: Thu, 18 Jan 1996 16:41:17 GMT
  1236. Organization: Apple Computer, Inc.
  1237.  
  1238. In article <sdr-1501961047080001@gateway.sdr.com.au>, sdr@sdr.com.au
  1239. (Roger Lainson) wrote:
  1240.  
  1241. > Thanks to everybody who helped with my query about how to name a printer
  1242. > job. The concensus of the comments (plus a few experiments) is that the
  1243. > job name takes the name of the frontmost window, which must be visible but
  1244. > which can be offscreen. Floaters are ignored (as in FrontWindow). The name
  1245. > is picked up by the call to PrJobDialog (or PrValidate if you ain't using
  1246. > a dialog (tut tut)).
  1247. > While on print jobs the following may be of interest. IM Vol II implies
  1248. > that in the TPrint structure, prJob.iCopies can be used to examine the
  1249. > number of copies specified in the print dialog (Think Reference says this
  1250. > explicitly). My experience (with the Laserwrite 8 driver) is that
  1251. > prJob.iCopies stays obstinately at 1, but prXInfo.iRowBytes *does* reflect
  1252. > the number of copies (and can be used to *set* the number of copies for
  1253. > that matter). 
  1254. > Seems a bit odd to have a field documented for the purpose and then use a
  1255. > different one, but presumably I shouldn't be messing with the print copies
  1256. > anyway!
  1257.  
  1258. When you use the QuickDraw GX printing APIs you can *directly* specify
  1259. to the print record both your document name, and the number of copies.
  1260. In fact, you can set EVERY SINGLE thing that a user might set in the
  1261. print dialog yourself through a public API, with no mucking about.
  1262.  
  1263. In addition, GX directly supports dialogless (including no status
  1264. dialogs) printing, so you don't have to muck about to get that either.
  1265.  
  1266. I mention this because it's pretty much a one for one translation of
  1267. your existing print loop to use GX printing when it's available.
  1268. This way, you get neat cool new features when GX is there, but
  1269. still run as you do today when it is not.
  1270.  
  1271. SimpleText does this, and it really is very trivial.  Details on how
  1272. to do it appear in a _develop_ article by Dave Hersey a while back.
  1273.  
  1274. Anyway, it's something you should consider when working on an application.
  1275.  
  1276. -- 
  1277.  Tom Dowdy                  Internet: dowdy@apple.COM
  1278.  Apple Computer MS:302-3KS  UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy
  1279.  1 Infinite Loop            AppleLink: DOWDY1
  1280.  Cupertino, CA 95014       
  1281.  "The 'Ooh-Ah' Bird is so called because it lays square eggs."
  1282.  
  1283. ---------------------------
  1284.  
  1285. >From Charles Thomas <cfthoma1@facstaff.wisc.edu>
  1286. Subject: Problems with UPP's
  1287. Date: 4 Jan 1996 17:12:13 GMT
  1288. Organization: IMR, University of Wisconsin-Madison
  1289.  
  1290.  
  1291. Hi.
  1292.  
  1293. Still struggling with properly implementing the use of UPP's.  Mostly,
  1294. the books I've got use ControlProc's as examples.  My specific code is
  1295. below and it doesn't work, so I'm obviously doing something wrong.  I'm
  1296. trying to replace a GrowZoneProcPtr with a UniversalProcPtr.
  1297.  
  1298. What I'd like to know is what the correct code should be and how to find
  1299. out the correct parameters to pass NewRoutineDescriptor, specifically the
  1300. second and third parameters.  
  1301.  
  1302. Thanks for any help.
  1303.  
  1304. //*******CODE FOLLOWS*****
  1305.  
  1306. //emergency_memory is an external global variable
  1307.  
  1308. void            initialize_emergency_memory   (void)
  1309. {
  1310.  
  1311.  
  1312.         UniversalProcPtr                my_growzoneUPP = NIL;
  1313.  
  1314.         
  1315.         emergency_memory = NewHandle(EMERGENCY_MEMORY_SIZE);
  1316.         if (emergency_memory == NIL)
  1317.         {
  1318.                 put_message("\pThere has been a memory allocation error.");
  1319.                 ExitToShell();
  1320.         }
  1321.         
  1322.         my_growzoneUPP = NewRoutineDescriptor((ProcPtr)MyGrowZone, 
  1323.                                                                                                                                         kPascalStackBased, kPowerPCISA);
  1324.         SetGrowZone(my_growzoneUPP);
  1325.         
  1326.         DisposeRoutineDescriptor(my_growzoneUPP);
  1327.  
  1328. //**** The above three lines replace the following line from the 68k code:
  1329. //              SetGrowZone((GrowZoneProcPtr)&MyGrowZone);
  1330.         
  1331.         return;
  1332.  
  1333. }// end of initialize_emergency_memory()
  1334.  
  1335. +++++++++++++++++++++++++++
  1336.  
  1337. >From vance@webgenesis.com (Vance Huntley)
  1338. Date: Thu, 04 Jan 1996 19:13:23 -0500
  1339. Organization: WebGenesis, Inc.
  1340.  
  1341. In article <4ch1pd$2092@news.doit.wisc.edu>, Charles Thomas
  1342. <cfthoma1@facstaff.wisc.edu> wrote:
  1343.  
  1344. > Hi.
  1345. > Still struggling with properly implementing the use of UPP's.  Mostly,
  1346. > the books I've got use ControlProc's as examples.  My specific code is
  1347. > below and it doesn't work, so I'm obviously doing something wrong.  I'm
  1348. > trying to replace a GrowZoneProcPtr with a UniversalProcPtr.
  1349. > What I'd like to know is what the correct code should be and how to find
  1350. > out the correct parameters to pass NewRoutineDescriptor, specifically the
  1351. > second and third parameters.  
  1352.  
  1353. The trick is to use the UPP stuff defined for you in the UniversalHeaders
  1354. wherever possible.  I believe that they have macros for creating UPP's
  1355. appropriate for every callback in the Toolbox.
  1356.  
  1357. Try this:
  1358.  
  1359. [clip]
  1360. GrowZoneUPP myGrowZoneUPP = NewGrowZoneProc(MyGrowZone);
  1361. >         SetGrowZone(myGrowZoneUPP);
  1362.  
  1363. and DONT DISPOSE OF THE ROUTINE DESCRIPTOR, since the mixed mode manager
  1364. will need it whenever the routine is actually called.  The memory will be
  1365. freed automatically when your app quits.
  1366.  
  1367. Good Luck-
  1368.  
  1369. Vance
  1370.  
  1371. +++++++++++++++++++++++++++
  1372.  
  1373. >From zobkiw@triplesoft.com (Joe Zobkiw)
  1374. Date: Thu, 04 Jan 1996 19:34:13 -0500
  1375. Organization: TripleSoft Inc.
  1376.  
  1377. In article <4ch1pd$2092@news.doit.wisc.edu>, Charles Thomas
  1378. <cfthoma1@facstaff.wisc.edu> wrote:
  1379.  
  1380. >Still struggling with properly implementing the use of UPP's.
  1381.  
  1382. ::: stuff deleted :::
  1383.  
  1384. >        my_growzoneUPP = NewRoutineDescriptor((ProcPtr)MyGrowZone, 
  1385. >                         kPascalStackBased, kPowerPCISA);
  1386.  
  1387. Look in memory.h and use the NewGrowZoneProc macro that is there. You can
  1388. then use the resulting GrowZoneUPP as your UPP.
  1389.  
  1390. Good luck!
  1391.  
  1392. Joe Zobkiw                         <mailto:zobkiw@triplesoft.com>
  1393. TripleSoft Inc.                      <http://www.triplesoft.com/>
  1394. Specializing in Custom Macintosh Software Development & Solutions
  1395. - ---------------------------------------------------------------
  1396. Macintosh programmers! Check out "A Fragment of Your Imagination"
  1397.    from Addison-Wesley <http://www.triplesoft.com/fragment/>
  1398.  
  1399. +++++++++++++++++++++++++++
  1400.  
  1401. >From DaveZ@mailbag.com (David B. Zwiefelhofer)
  1402. Date: Fri, 05 Jan 1996 11:56:51 -0500
  1403. Organization: Utility Reduction Specialists, Inc.
  1404.  
  1405. In article <vance-0401961913230001@mainframe.webgenesis.com>,
  1406. vance@webgenesis.com (Vance Huntley) wrote:
  1407.  
  1408. [snip]
  1409. > and DONT DISPOSE OF THE ROUTINE DESCRIPTOR, since the mixed mode manager
  1410. > will need it whenever the routine is actually called.  The memory will be
  1411. > freed automatically when your app quits.
  1412.  
  1413. Really? Now I'm confused. When can I and when can I not use
  1414. DisposeRoutineDescriptor?
  1415.  
  1416. Thanks,
  1417.  
  1418. Dave
  1419.  
  1420. -- 
  1421. David B. Zwiefelhofer
  1422. Utility Reduction Specialists, Inc.
  1423. 1605 Monroe Street, Suite 110
  1424. Madison, WI  53211-2052
  1425. (608) 258-8965
  1426. (608) 258-9686 FAX
  1427.  
  1428. +++++++++++++++++++++++++++
  1429.  
  1430. >From "Andrew C. Plotkin" <erkyrath+@CMU.EDU>
  1431. Date: Fri,  5 Jan 1996 20:14:02 -0500
  1432. Organization: Carnegie Mellon, Pittsburgh, PA
  1433.  
  1434. DaveZ@mailbag.com (David B. Zwiefelhofer) writes:
  1435. > In article <vance-0401961913230001@mainframe.webgenesis.com>,
  1436. > vance@webgenesis.com (Vance Huntley) wrote:
  1437. > [snip]
  1438. > > 
  1439. > > and DONT DISPOSE OF THE ROUTINE DESCRIPTOR, since the mixed mode manager
  1440. > > will need it whenever the routine is actually called.  The memory will be
  1441. > > freed automatically when your app quits.
  1442. > > 
  1443. > Really? Now I'm confused. When can I and when can I not use
  1444. > DisposeRoutineDescriptor?
  1445.  
  1446. It's like any other allocated object; you can dispose of it once
  1447. you're sure that it will never be used again. 
  1448.  
  1449. For example, if I'm passing a file-filter callback in to
  1450. StandardGetFile, I usually allocate the routine descriptor before
  1451. calling StandardGetFile and dispose of it afterwards. That's because I
  1452. know that the toolbox will only call it during that StandardGetFile
  1453. call. 
  1454.  
  1455. But if you create a descriptor and put it somewhere where it will be
  1456. used for the rest of your program's lifetime, you shouldn't dispose of
  1457. it until the end of that lifetime. 
  1458.  
  1459. --Z
  1460.  
  1461. "And Aholibamah bare Jeush, and Jaalam, and Korah: these were the borogoves..."
  1462.  
  1463. +++++++++++++++++++++++++++
  1464.  
  1465. >From DaveZ@mailbag.com (David B. Zwiefelhofer)
  1466. Date: Fri, 12 Jan 1996 16:08:14 -0500
  1467. Organization: Utility Reduction Specialists, Inc.
  1468.  
  1469. In article <kkvQnOC00WB3Mfb8AC@andrew.cmu.edu>, "Andrew C. Plotkin"
  1470. <erkyrath+@CMU.EDU> wrote:
  1471.  
  1472. > DaveZ@mailbag.com (David B. Zwiefelhofer) writes:
  1473. > > In article <vance-0401961913230001@mainframe.webgenesis.com>,
  1474. > > vance@webgenesis.com (Vance Huntley) wrote:
  1475. > > 
  1476. > > [snip]
  1477. > > > 
  1478. > > > and DONT DISPOSE OF THE ROUTINE DESCRIPTOR, since the mixed mode manager
  1479. > > > will need it whenever the routine is actually called.  The memory will be
  1480. > > > freed automatically when your app quits.
  1481. > > > 
  1482. > > 
  1483. > > Really? Now I'm confused. When can I and when can I not use
  1484. > > DisposeRoutineDescriptor?
  1485. > It's like any other allocated object; you can dispose of it once
  1486. > you're sure that it will never be used again. 
  1487. > For example, if I'm passing a file-filter callback in to
  1488. > StandardGetFile, I usually allocate the routine descriptor before
  1489. > calling StandardGetFile and dispose of it afterwards. That's because I
  1490. > know that the toolbox will only call it during that StandardGetFile
  1491. > call. 
  1492. > But if you create a descriptor and put it somewhere where it will be
  1493. > used for the rest of your program's lifetime, you shouldn't dispose of
  1494. > it until the end of that lifetime. 
  1495.  
  1496. Well, that makes sense. But now I'm truly confused. I have used the UPPs
  1497. for apple event handlers. The thing that confuses me is that I was
  1498. disposing of them immediately after AEInstallEventHandler-ing them
  1499. *without* any problems. I haven't compiled this for PPC yet. 
  1500.  
  1501. So can you elaborate further on this? Why is this working for me?
  1502. Something to do with 68K as opposed to PPC?
  1503.  
  1504. Thanks,
  1505.  
  1506. Dave
  1507.  
  1508. -- 
  1509. David B. Zwiefelhofer
  1510. Utility Reduction Specialists, Inc.
  1511. 1605 Monroe Street, Suite 110
  1512. Madison, WI  53211-2052
  1513. (608) 258-8965
  1514. (608) 258-9686 FAX
  1515.  
  1516. +++++++++++++++++++++++++++
  1517.  
  1518. >From tulip@tiac.net (Ed Anson)
  1519. Date: Fri, 12 Jan 1996 21:38:42 -0500
  1520. Organization: Tulip Software
  1521.  
  1522. In article <DaveZ-1201961608140001@msn_3_1.binc.net>, DaveZ@mailbag.com
  1523. (David B. Zwiefelhofer) wrote:
  1524.  
  1525.  
  1526. > Well, that makes sense. But now I'm truly confused. I have used the UPPs
  1527. > for apple event handlers. The thing that confuses me is that I was
  1528. > disposing of them immediately after AEInstallEventHandler-ing them
  1529. > *without* any problems. I haven't compiled this for PPC yet. 
  1530. > So can you elaborate further on this? Why is this working for me?
  1531. > Something to do with 68K as opposed to PPC?
  1532.  
  1533. YES.
  1534.  
  1535. When compiling for 68K, the macros for creating UPPs just return procedure
  1536. pointers. The macros for disposing UPPs do absolutely nothing. So the
  1537. installed event handler still works even after you "dispose" of the UPP.
  1538.  
  1539. But when you compile for PPC those macros actually allocate and dispose
  1540. blocks of memory containing the magic PPC stuff. In this case, if you
  1541. dispose the UPP, the event handler won't work and you will probably crash,
  1542. because the system will branch into a block of freed memory.
  1543.  
  1544. - --------------------
  1545. Ed Anson
  1546. Tulip Software
  1547. Andover, MA 01810   Check out my WWW page:
  1548. U.S.A.              <http://www.tiac.net/users/tulip/home.html>
  1549.  
  1550. +++++++++++++++++++++++++++
  1551.  
  1552. >From dnebing@epix.net (Dave Nebinger)
  1553. Date: Mon, 15 Jan 1996 13:54:47 -0500
  1554. Organization: KHP Services, Inc
  1555.  
  1556. In article <DaveZ-1201961608140001@msn_3_1.binc.net>, DaveZ@mailbag.com
  1557. (David B. Zwiefelhofer) wrote:
  1558. > Well, that makes sense. But now I'm truly confused. I have used the UPPs
  1559. > for apple event handlers. The thing that confuses me is that I was
  1560. > disposing of them immediately after AEInstallEventHandler-ing them
  1561. > *without* any problems. I haven't compiled this for PPC yet. 
  1562.  
  1563. The reason you haven't seen any problems yet is because you haven't
  1564. compiled for PPC.  68k code doesn't use UPPs (until the 68k CFM is
  1565. available), so your quick disposal doesn't really do anything (if you look
  1566. at the code you are generating, NewRoutineDescriptor() and 
  1567. DisposeRoutineDescriptor() expand to nothing for 68k compilers).
  1568.  
  1569. When you move to PPC/CFM compilation, that's when your method
  1570. will fail miserably.  Your best bet is just to create the routines
  1571. and forget about them (unless they are system handlers; those you
  1572. will have to dispose of later).  After your app dies all of the memory
  1573. that you have allocated is returned to the system so you don't have
  1574. to worry about upp's being stranded.
  1575.  
  1576. Dave.
  1577.  
  1578. ==========================================================
  1579. Dave Nebinger                             dnebing@epix.net
  1580.              The Alt.Sources.Mac Archivist
  1581.  
  1582. ---------------------------
  1583.  
  1584. >From kryan@aoc.nrao.edu (Kevin Ryan)
  1585. Subject: Q: Do QuickDraw routines execute faster Offscreen?
  1586. Date: 10 Jan 1996 16:07:10 GMT
  1587. Organization: National Radio Astronomy Observatory
  1588.  
  1589. My Daughter and I are doing a project in cellular automata and have a screen
  1590. of dozens of little QuickDraw Regions ('cells') roaming around looking for
  1591. 'food' (using GetCPixel).  As is no surprise, most of the program time is
  1592. spent on the screen.  We envision long running (overnight) experiments where
  1593. we want to perform as many cycles as fast as possible, but won't be watching
  1594. the screen.  The operation of the program however, depends on the QuickDraw
  1595. routines (i.e. if GetCPixel returns a 'food' - he don't go hungry!).
  1596.  
  1597. My question is: can we implement a 'fast-forward' function by moving the 
  1598. screen routines to an offscreen GWorld (we would give up being able to
  1599. see what was happening for the sake of speed).  Will the same QuickDraw
  1600. routines execute faster offscreen where there is no actual screen drawing
  1601. taking place?
  1602.  
  1603. I've read the Inside Mac books and Technical Notes but they all simply say
  1604. that offscreen drawing makes for smoother screen updates - "you can create
  1605. the image offscreen, then update the screen when it is all done".  This 
  1606. does not tell me if the QuickDraw routines will execute faster or not.
  1607.  
  1608. My daughter's Mac has built-in video and mine uses an old 8-bit NuBus card. 
  1609.  
  1610. Thank you,
  1611. Kevin Ryan
  1612.  
  1613. -- 
  1614. - -----------------------------------------------------------------------------
  1615. Kevin Ryan                              National Radio Astronomy Observatory
  1616. Scientific Programmer                           Array Operations Center
  1617. kryan@aoc.nrao.edu                        P.O. Box O  Socorro, NM   87801
  1618. - -----------------------------------------------------------------------------
  1619.  
  1620.  
  1621.  
  1622.  
  1623. +++++++++++++++++++++++++++
  1624.  
  1625. >From pottier@felouque.ens.fr (Francois Pottier)
  1626. Date: 11 Jan 1996 13:56:46 GMT
  1627. Organization: Ecole Normale Superieure, Paris
  1628.  
  1629. In article <4d0o7e$9vj@chaos.aoc.nrao.edu>,
  1630. Kevin Ryan <kryan@aoc.nrao.edu> wrote:
  1631.  
  1632. >My question is: can we implement a 'fast-forward' function by moving the 
  1633. >screen routines to an offscreen GWorld (we would give up being able to
  1634. >see what was happening for the sake of speed).  Will the same QuickDraw
  1635. >routines execute faster offscreen where there is no actual screen drawing
  1636. >taking place?
  1637.  
  1638. Yes, QuickDraw is faster offscreen, because it doesn't have to perform
  1639. various tests to see which monitor the pixel is falling into, which
  1640. window & palette are active, etc. I don't know whether the speed
  1641. difference is substantial, though.
  1642.  
  1643. However, the biggest advantage of using offscreen worlds is that you
  1644. can then stop using SetCPixel and GetCPixel, which are very, very slow.
  1645. Instead you can very easily roll your own routines. The basic idea is
  1646. this: use GetGWorldPixMap to obtain a handle to the world's pixmap,
  1647. then GetPixBaseAddr to get the pixmap's base address. Once this is
  1648. done, do a simple computation to convert a (x, y) pair into an
  1649. offset into the pixmap. Basically
  1650.  
  1651.   rowBytes * y + x
  1652.  
  1653. in 8 bit mode (you would use 2*x in 16 bit mode, etc.). Once you
  1654. know the address of the point, you can write or read its color
  1655. easily. This is several orders of magnitude faster than Get/SetCPixel.
  1656.  
  1657. This kind of trick should be used only on offscreen worlds, because
  1658. it is more complex with the screen itself (several monitors, dealing
  1659. with video RAM, etc.)
  1660.  
  1661. I hope this helps,
  1662.  
  1663.  
  1664. -- 
  1665. Francois
  1666. pottier@dmi.ens.fr
  1667. http://www.eleves.ens.fr:8080/home/pottier/
  1668.  
  1669. +++++++++++++++++++++++++++
  1670.  
  1671. >From s868672@umslvma.umsl.edu (Tracy Findley)
  1672. Date: 11 Jan 1996 17:55:45 GMT
  1673. Organization: University of Missouri - St. Louis
  1674.  
  1675. In article <4d0o7e$9vj@chaos.aoc.nrao.edu>, kryan@aoc.nrao.edu wrote:
  1676.  
  1677. > My Daughter and I are doing a project in cellular automata and have a screen
  1678. > of dozens of little QuickDraw Regions ('cells') roaming around looking for
  1679. > 'food' (using GetCPixel).  As is no surprise, most of the program time is
  1680. > spent on the screen.  We envision long running (overnight) experiments where
  1681. > we want to perform as many cycles as fast as possible, but won't be watching
  1682. > the screen.  The operation of the program however, depends on the QuickDraw
  1683. > routines (i.e. if GetCPixel returns a 'food' - he don't go hungry!).
  1684. > My question is: can we implement a 'fast-forward' function by moving the 
  1685. > screen routines to an offscreen GWorld (we would give up being able to
  1686. > see what was happening for the sake of speed).  Will the same QuickDraw
  1687. > routines execute faster offscreen where there is no actual screen drawing
  1688. > taking place?
  1689. > I've read the Inside Mac books and Technical Notes but they all simply say
  1690. > that offscreen drawing makes for smoother screen updates - "you can create
  1691. > the image offscreen, then update the screen when it is all done".  This 
  1692. > does not tell me if the QuickDraw routines will execute faster or not.
  1693. > My daughter's Mac has built-in video and mine uses an old 8-bit NuBus card. 
  1694. > Thank you,
  1695. > Kevin Ryan
  1696.  
  1697. Yes, provisionally.  When QuickDraw has to write to the screen, no caching
  1698. can be done so memory access occurs more slowly for drawing to the screen;
  1699. _if_ caching is available for that particular machine.
  1700.  
  1701. Second:  for fantastic speed-ups; forget about GetCPixel and use offscreen
  1702. GWorlds and access the pixels yourself; check out "Develop Issue 10" found
  1703. at
  1704.  
  1705. http://www.info.apple.com
  1706.  
  1707. somewhere in "Developer Services."  The article "Drawing in GWorlds for
  1708. Speed and Versatility" describes in detail how to do exactly what you
  1709. want.  They took a routine that used GetCPixel and SetCPixel to perform an
  1710. operation on an image and replaced it so that instead of taking 10 seconds
  1711. it took about 1/60th of a second!
  1712.  
  1713. You _will_ have to blit the gworld back to the screen as often as you want
  1714. to see it, of course.
  1715.  
  1716. Hope this helps,
  1717. David Findley
  1718.  
  1719. -- 
  1720. Tracy Findley
  1721. s868672@umslvma.umsl.edu
  1722.  
  1723. +++++++++++++++++++++++++++
  1724.  
  1725. >From Mark Barton <mbarton@icrr.u-tokyo.ac.jp>
  1726. Date: Fri, 19 Jan 1996 06:26:57 GMT
  1727. Organization: Institute for Cosmic Ray Research, Tokyo Uni.
  1728.  
  1729. In article <4d0o7e$9vj@chaos.aoc.nrao.edu> Kevin Ryan, kryan@aoc.nrao.edu
  1730. writes:
  1731. >Subject: Q: Do QuickDraw routines execute faster Offscreen?
  1732. >From: Kevin Ryan, kryan@aoc.nrao.edu
  1733. >Date: 10 Jan 1996 16:07:10 GMT
  1734. >>My Daughter and I are doing a project in cellular automata and have a screen
  1735. >of dozens of little QuickDraw Regions ('cells') roaming around looking for
  1736. >'food' (using GetCPixel).  As is no surprise, most of the program time is
  1737. >spent on the screen.  We envision long running (overnight) experiments where
  1738. >we want to perform as many cycles as fast as possible, but won't be watching
  1739. >the screen.  The operation of the program however, depends on the QuickDraw
  1740. >routines (i.e. if GetCPixel returns a 'food' - he don't go hungry!).
  1741. >
  1742. >My question is: can we implement a 'fast-forward' function by moving the 
  1743. >screen routines to an offscreen GWorld (we would give up being able to
  1744. >see what was happening for the sake of speed).  Will the same QuickDraw
  1745. >routines execute faster offscreen where there is no actual screen drawing
  1746. >taking place?
  1747. >
  1748. >I've read the Inside Mac books and Technical Notes but they all simply say
  1749. >that offscreen drawing makes for smoother screen updates - "you can create
  1750. >the image offscreen, then update the screen when it is all done".  This 
  1751. >does not tell me if the QuickDraw routines will execute faster or not.
  1752. >
  1753. >My daughter's Mac has built-in video and mine uses an old 8-bit NuBus card. 
  1754.  
  1755. Yes you are definitely thinking along the right lines.  There is a 
  1756. particularly large amount of overhead in each call to the graphics 
  1757. routines so the more procedure calls you can eliminate the better.  I 
  1758. wrote such a game once and after a lot of trial and error achieved a 
  1759. speedup of a factor of thirty or more.  
  1760.  
  1761. The fastest way to do this of course is to interrogate QuickDraw to 
  1762. find out where the screen is and write to it directly.  However this 
  1763. requires you to write and debug a lot of arithmetic and the details of 
  1764. the arithmetic depend on the screen size, screen depth, window 
  1765. position etc.  Unless you spend a lot of effort allowing for different 
  1766. cases the program will be completely non-portable.
  1767.  
  1768. A better method which is nearly as fast is to maintain the cellular 
  1769. automaton world in an array offscreen which is of the right size and 
  1770. shape to work as a bitmap or pixmap.  There are a few rules, such as 
  1771. that there have to be an even number of bytes in each row, but 
  1772. generally you get to choose.  Create a grafPort or cGrafPort of the 
  1773. right size and shape to match your array and install a pointer to the 
  1774. array in it.  Then simply use CopyBits to copy the array to the 
  1775. physical screen.  By using the scale parameters to CopyBits you can 
  1776. make the on-screen pixels any size you like.
  1777.  
  1778. I was working with a particular system which was most interesting with 
  1779. around 16-20 states per cell, so I chose an array of bytes and told 
  1780. QuickDraw that it was a 256 colour pixmap.  If you are programming 
  1781. something like Life with two states then you can make the array a 
  1782. simple (black and white) bitmap.  Most programming languages are not 
  1783. set up to handle arrays of bits but it is trivial to write functions 
  1784. or macros which will do the job.
  1785.  
  1786. I can send you some Pascal or C code if you are interested.  It 
  1787. doesn't actually work, but it's very very close.  The Pascal version 
  1788. did work but broke mysteriously when I upgraded to System 7 for 
  1789. reasons I never managed to work out, and the C is a translation which 
  1790. is fully debugged except for the same error as in the Pascal(!).
  1791.  
  1792. Cheers,
  1793.  
  1794. Mark B.
  1795.  
  1796.  
  1797. ---------------------------
  1798.  
  1799. >From Carl R. Osterwald <carl_osterwald@nrel.gov>
  1800. Subject: SetCCursor inside a VBL task?
  1801. Date: 18 Jan 1996 22:37:36 GMT
  1802. Organization: National Renewable Energy Laboratory
  1803.  
  1804. I have used SetCCursor inside a VBL task to produce an animated cursor
  1805. without problems for several years, but now find that it crashes on a
  1806. 7200 running 7.5.2 (using SetCursor with a B&W cursor does not crash).
  1807. Is there something inherently wrong with doing this, or is there a way
  1808. around it?
  1809.  
  1810. +++++++++++++++++++++++++++
  1811.  
  1812. >From mclow@mailhost2.csusm.edu (Marshall Clow)
  1813. Date: Sat, 20 Jan 1996 22:25:32 -0800
  1814. Organization: Aladdin Systems
  1815.  
  1816. In article <4dmi3g$n1l@nrel.nrel.gov>, Carl R. Osterwald
  1817. <carl_osterwald@nrel.gov> wrote:
  1818.  
  1819. >I have used SetCCursor inside a VBL task to produce an animated cursor
  1820. >without problems for several years, but now find that it crashes on a
  1821. >7200 running 7.5.2 (using SetCursor with a B&W cursor does not crash).
  1822. >Is there something inherently wrong with doing this, or is there a way
  1823. >around it?
  1824. >
  1825.  
  1826. You can't do anything inside a VBL completion routine that will move memory.
  1827.  
  1828. I don't see anything in Inside Mac that says either way if SetCCursor
  1829. moves memory. However, IM-V pp 75 says: "At the time the cursor is set, it
  1830. is expanded to the current screen depth so that it can be drawn rapidly."
  1831.  
  1832. That sounds to me like allocating/resizing memory.
  1833.  
  1834. -- 
  1835. Marshall Clow
  1836. Aladdin Systems
  1837.  
  1838. "They that can give up essential liberty to obtain a little temporary
  1839.  safety deserve neither liberty nor safety." -- Benjamin Franklin
  1840.  _Historical Review of Pennsylvania_, 1759
  1841.  
  1842. +++++++++++++++++++++++++++
  1843.  
  1844. >From rickgenter@aol.com (RickGenter)
  1845. Date: 19 Jan 1996 10:02:02 -0500
  1846. Organization: America Online, Inc. (1-800-827-6364)
  1847.  
  1848. >>>
  1849. Is there something inherently wrong with doing this, or is there a way
  1850. around it?
  1851. <<<
  1852.  
  1853. I believe SetCCursor is documented as potentially moving memory, which you
  1854. can not do safely within a VBL handler.
  1855.  
  1856. Rick Genter
  1857. Papyrus Design Group, Inc.
  1858.  
  1859. ---------------------------
  1860.  
  1861. >From dunham@pensee.com (David Dunham)
  1862. Subject: Using STL with pointers to objects
  1863. Date: Tue, 02 Jan 1996 22:30:58 -0800
  1864. Organization: Pensee Corporation
  1865.  
  1866. I'm trying to convert the ODFDraw sample to an editor which keeps track of
  1867. an array (rather than an ordered list) of embedded parts. Since ODF
  1868. doesn't have an array class, I decided to try to use STL as the basis for
  1869. my array. The abbreviated header is
  1870.  
  1871. class FW_CLASS_ATTR CThingList {
  1872.    unsigned long     Count() const        { return fImplementation.size(); }
  1873.    FW_Boolean        IsEmpty() const         { return fImplementation.empty(); }
  1874.  
  1875.    CThing*           First()              { return fImplementation.empty()
  1876. ? kODNULL : fImplementation.front(); }
  1877.    CThing*           Last()               { return fImplementation.back(); }
  1878.    CThing*           Nth(const long aPos) { return fImplementation[aPos]; }
  1879.  
  1880.    void           AddLast(CThing* anElement) {
  1881. fImplementation.push_back(anElement); }
  1882.  
  1883. private:
  1884.    vector<CThing*>      fImplementation;
  1885. };
  1886.  
  1887. And this all seems to work, except that when a CThingList is destroyed,
  1888. ~CThing is never called. I've yet to see an example of STL vectors which
  1889. are an array of pointers, rather than an array of objects.
  1890.  
  1891. Should I be using vector<CThing> instead? If so, how would I dynamically
  1892. allocate CThings to add to the list?
  1893.  
  1894. David Dunham   Pensee Corporation   dunham@pensee.com
  1895. Voice/Fax: 206 783 7404             http://www.pensee.com/dunham/
  1896.     "I say we should listen to the customers and give them what they want."
  1897.     "What they want is better products for free." --Scott Adams
  1898.  
  1899. +++++++++++++++++++++++++++
  1900.  
  1901. >From kenp@nmrfam.wisc.edu (Ken Prehoda)
  1902. Date: Wed, 03 Jan 1996 09:18:14 -0600
  1903. Organization: Univ of Wisconsin-Madison, Dept of Biochemistry
  1904.  
  1905. In article <dunham-0201962230580001@feather.pensee.com>, dunham@pensee.com
  1906. (David Dunham) wrote:
  1907.  
  1908. : I'm trying to convert the ODFDraw sample to an editor which keeps track of
  1909. : an array (rather than an ordered list) of embedded parts. Since ODF
  1910. : doesn't have an array class, I decided to try to use STL as the basis for
  1911. : my array. The abbreviated header is
  1912. : class FW_CLASS_ATTR CThingList {
  1913. :    unsigned long     Count() const        { return fImplementation.size(); }
  1914. :    FW_Boolean        IsEmpty() const         { return
  1915. fImplementation.empty(); }
  1916. :    CThing*           First()              { return fImplementation.empty()
  1917. : ? kODNULL : fImplementation.front(); }
  1918. :    CThing*           Last()               { return fImplementation.back(); }
  1919. :    CThing*           Nth(const long aPos) { return fImplementation[aPos]; }
  1920. :    void           AddLast(CThing* anElement) {
  1921. : fImplementation.push_back(anElement); }
  1922. : private:
  1923. :    vector<CThing*>      fImplementation;
  1924. : };
  1925. : And this all seems to work, except that when a CThingList is destroyed,
  1926. : ~CThing is never called. I've yet to see an example of STL vectors which
  1927. : are an array of pointers, rather than an array of objects.
  1928.  
  1929. If you store pointers to objects, you have to handle their destruction yourself.
  1930.  
  1931. : Should I be using vector<CThing> instead? If so, how would I dynamically
  1932. : allocate CThings to add to the list?
  1933.  
  1934. It is better to have stl store the objects themselves.  Sometimes you are
  1935. forced to store pointers, however.  An example would be storing
  1936. heterogenous objects that descend from a common base class.
  1937.  
  1938. To dynamically add CThing's to the vector
  1939.  
  1940. CThing aThing;
  1941.  
  1942. fImplementation.push_back(aThing);
  1943.  
  1944. or
  1945.  
  1946. CThing* aThing = new CThing;
  1947.  
  1948. fImplementation.push_back(*aThing);
  1949.  
  1950. delete aThing;
  1951. _____________________________________________________________________________
  1952. Ken Prehoda                                              kenp@nmrfam.wisc.edu
  1953. Department of Biochemistry                         http://www.nmrfam.wisc.edu
  1954. University of Wisconsin-Madison                             Tel: 608-263-9498
  1955. 420 Henry Mall                                              Fax: 608-262-3453
  1956.  
  1957. +++++++++++++++++++++++++++
  1958.  
  1959. >From Garth Cummings <gcummings@amoco.com>
  1960. Date: 3 Jan 1996 15:16:02 GMT
  1961. Organization: Vysis, Inc.
  1962.  
  1963. Generally STL classes are used to contain objects by value rather than by
  1964. reference. Thus a vector<CThing> is more idiomatic than vector<CThing*>.
  1965. STL containers contain copies of the objects that are inserted to the
  1966. container. 
  1967.  
  1968. However, a container of pointers is perfectly valid with a couple of
  1969. caveats. First, you become responsible for managing the creation and
  1970. deletion of objects whose addresses are in the container.  Second, if you
  1971. are using an ordered container such as set, you will probably want to
  1972. provide an operator> and operator== for your pointers that dereference
  1973. the pointers to compare some attribute of the actual objects. Otherwise
  1974. the set would be ordered on the addresses themselves.
  1975.  
  1976. I've found the Web site
  1977. http://www.xraylith.wisc.edu/~khan/software/stl/STL.newbie.html very
  1978. useful for getting help, sample code, etc. on STL.
  1979.  
  1980. Cheers,
  1981. Garth
  1982.  
  1983. Garth Cummings
  1984. Project Leader
  1985. Vysis, Inc.
  1986.  
  1987. +++++++++++++++++++++++++++
  1988.  
  1989. >From fuz@deltanet.com (Scott Ellsworth)
  1990. Date: 3 Jan 1996 19:32:07 GMT
  1991. Organization: Deltanet Communications, Inc.
  1992.  
  1993. In article <dunham-0201962230580001@feather.pensee.com>,
  1994. David Dunham <dunham@pensee.com> wrote:
  1995. >   vector<CThing*>      fImplementation;
  1996. >And this all seems to work, except that when a CThingList is destroyed,
  1997. >~CThing is never called. I've yet to see an example of STL vectors which
  1998. >are an array of pointers, rather than an array of objects.
  1999. >
  2000. >Should I be using vector<CThing> instead? If so, how would I dynamically
  2001. >allocate CThings to add to the list?
  2002. >
  2003.  
  2004. Have you read Mumit Khan's STL page and the many pages devoted to it at 
  2005. rpi?  When I needed to do this, I found them a great help.  The solution 
  2006. I chose was a wrapper class, called a BuildingHolder.  Essentially, it 
  2007. was a smart pointer which handled the deletion of the object pointed to, 
  2008. and which was otherwise fairly trivial.
  2009.  
  2010. e.g. (from memory)
  2011.  
  2012. class BuildingHolder {
  2013.         public:
  2014.         BuildingHolder() { held=0; }
  2015.         BuldingHolder(const Building & in) { held=in; }
  2016.         BuldingHolder(const BuildingHolder & in) { held=in.MakeCopy(); }
  2017.         ~BuildingHolder() { if (held) delete held; }
  2018.         Building * GetIt(void) { return held; }
  2019.         Building * MakeCopy(void) { ... code to copy with ref counts ... }
  2020.         private:
  2021.         Building * held;
  2022.         };
  2023.  
  2024. There was also some reference counting to make copies efficient and safe, 
  2025. but I suspect you get the idea.  In addition, you will need the usual ==. 
  2026. =, <, etc., that are aware of the refence counting.
  2027.  
  2028. Then, my lists, vectors, etc., became vector<BuildingHolder>, and so on.  
  2029. Also aided the introduction of leak detection diagnostics.
  2030.  
  2031. Scott
  2032. --
  2033. Scott Ellsworth          fuz@deltanet.com
  2034. "When a great many people are unable to find work, unemployment 
  2035. results" - Calvin Coolidge, (Stanley Walker, City Editor, p. 131 (1934))
  2036. "The barbarian is thwarted at the moat." - Scott Adams
  2037.  
  2038. +++++++++++++++++++++++++++
  2039.  
  2040. >From dunham@pensee.com (David Dunham)
  2041. Date: Wed, 03 Jan 1996 18:22:29 -0800
  2042. Organization: Pensee Corporation
  2043.  
  2044. In article <4celjn$6ac@news2.deltanet.com>, fuz@deltanet.com (Scott
  2045. Ellsworth) wrote:
  2046.  
  2047. > Have you read Mumit Khan's STL page and the many pages devoted to it at 
  2048. > rpi?  When I needed to do this, I found them a great help.  The solution 
  2049. > I chose was a wrapper class, called a BuildingHolder.  Essentially, it 
  2050. > was a smart pointer which handled the deletion of the object pointed to, 
  2051. > and which was otherwise fairly trivial.
  2052.  
  2053. Yeah, I finally figured it out (in part thanks to that page). No help at
  2054. all from "STL Tutorial and Reference Guide" by Musser and Saini :-( I
  2055. needed to do the two things that STL can't -- hold subclassed items, and
  2056. have the same item in multiple containers.
  2057.  
  2058. > There was also some reference counting to make copies efficient and safe, 
  2059.  
  2060. Does this mean all of your Building had to be in BuildingHolder?
  2061.  
  2062. > Also aided the introduction of leak detection diagnostics.
  2063.  
  2064. I assume it was the reference counting that helped with leaks?
  2065.  
  2066. David Dunham   Pensee Corporation   dunham@pensee.com
  2067. Voice/Fax: 206 783 7404             http://www.pensee.com/dunham/
  2068.     "I say we should listen to the customers and give them what they want."
  2069.     "What they want is better products for free." --Scott Adams
  2070.  
  2071. +++++++++++++++++++++++++++
  2072.  
  2073. >From fuz@deltanet.com (Scott Ellsworth)
  2074. Date: 4 Jan 1996 18:42:44 GMT
  2075. Organization: Deltanet Communications, Inc.
  2076.  
  2077. In article <dunham-0301961822290001@feather.pensee.com>,
  2078. David Dunham <dunham@pensee.com> wrote:
  2079. >In article <4celjn$6ac@news2.deltanet.com>, fuz@deltanet.com (Scott
  2080. >Ellsworth) wrote:
  2081. >
  2082. >> Have you read Mumit Khan's STL page and the many pages devoted to it at 
  2083. >> rpi?  When I needed to do this, I found them a great help.  The solution 
  2084. >> I chose was a wrapper class, called a BuildingHolder.  Essentially, it 
  2085. >> was a smart pointer which handled the deletion of the object pointed to, 
  2086. >> and which was otherwise fairly trivial.
  2087. >
  2088. >Yeah, I finally figured it out (in part thanks to that page). No help at
  2089. >all from "STL Tutorial and Reference Guide" by Musser and Saini :-( I
  2090. >needed to do the two things that STL can't -- hold subclassed items, and
  2091. >have the same item in multiple containers.
  2092.  
  2093. My personal favorite book on it presently is the Nelson book.  I am 
  2094. eyeing the STL<primer> book as well, since it seems to have a better 
  2095. discussion of some of the recent things from ObjectSpace.  Musser's book 
  2096. did not do much for me, but that might be because I have already read 
  2097. all of his pages at rpi, and so have already seen many of the things they 
  2098. were talking about.
  2099.  
  2100. I have found that STL can hold subclassed items and can hold multiple 
  2101. containers, as long as you are rather careful, and that the things that 
  2102. STL is holding are unique.  (i.e., I might have three BuildingHolders 
  2103. which hold the same thing, or which hold Buildings and Building 
  2104. subclasses, and STL does not mind.)  I have had success making it just 
  2105. hold pointers, but there are enough gotchas that some kind of wrapper has 
  2106. saved me a fair amount of grief.  I am thinking of making a templated 
  2107. holder class, given that my holders have looked pretty similar the last 
  2108. few times I have needed to use them.
  2109.  
  2110. >> There was also some reference counting to make copies efficient and safe, 
  2111. >
  2112. >Does this mean all of your Building had to be in BuildingHolder?
  2113.  
  2114. No, only those buldings that I wanted to put in STL structures and that I 
  2115. wanted to reference count.  Given the leak detection I also wanted, I 
  2116. ended up putting them all in BuildingHolder, and bulked up BuldingHolder 
  2117. from a smart pointer to a combination smart pointer and factory class.
  2118.  
  2119. >
  2120. >> Also aided the introduction of leak detection diagnostics.
  2121. >
  2122. >I assume it was the reference counting that helped with leaks?
  2123.  
  2124. Yep.  Also, I discovered DebugNew about the same time.  After stealing a 
  2125. few ideas from that, I put in a call to TickCount on creation and a 
  2126. vector in each object storing the time when the object was created, and 
  2127. matched it for deletions.  Ended up very slow, but helped when I was 
  2128. trying to find why I was drizzling memory all over the place.
  2129.  
  2130. A better solution was to have a counter that incremented on each 
  2131. creation, so if I ended up leaking, I could peer into memory and see 
  2132. which object was not being freed.  Not helpful if it was one in the 
  2133. middle, but very handy when I had an off-by-one error that was not 
  2134. freeing the first object allocated.
  2135.  
  2136. Scott
  2137. --
  2138. Scott Ellsworth          fuz@deltanet.com
  2139. "When a great many people are unable to find work, unemployment 
  2140. results" - Calvin Coolidge, (Stanley Walker, City Editor, p. 131 (1934))
  2141. "The barbarian is thwarted at the moat." - Scott Adams
  2142.  
  2143. +++++++++++++++++++++++++++
  2144.  
  2145. >From "Joseph N. Hall" <joseph@5sigma.com>
  2146. Date: 15 Jan 1996 04:01:09 GMT
  2147. Organization: 5 Sigma Productions
  2148.  
  2149. dunham@pensee.com (David Dunham) wrote:
  2150. >Yeah, I finally figured it out (in part thanks to that page). No help at
  2151. >all from "STL Tutorial and Reference Guide" by Musser and Saini :-( I
  2152. >needed to do the two things that STL can't -- hold subclassed items, and
  2153. >have the same item in multiple containers.
  2154.  
  2155. Err, to handle the subclassing problem, create template classes derived
  2156. from the container class.  The template class(es) should perform the
  2157. type coercions to/from the class of objects that the base container
  2158. class manipulates.  In other words:
  2159.  
  2160. class ObjectBase = base object class
  2161. class ObjectDerived1, ObjectDerived2 ... = classes derived from above 
  2162. class ContainerBase = base container class = container of ObjectBase
  2163. class ContainerDerived1 = template class derived from ContainerBase
  2164.   that does type coercions of ObjectDerived1 to/from ObjectBase but
  2165.   otherwise lets ContainerBase do the work = container of ObjectDerived1
  2166.  
  2167. ========================================================================
  2168. Joseph N. "Moof-in'" Hall       Proprietor,               V     V  sssss
  2169. joseph@5sigma.com           5 Sigma Productions            V   V  s   s 
  2170. P.O. Box 6250        software, multimedia, original music   V V   s   s 
  2171. Chandler AZ 85246  http://www.5sigma.com/joseph/Joseph.html  V     sss
  2172.  
  2173.  
  2174.  
  2175. ---------------------------
  2176.  
  2177. >From johnd@geko.net.au (John Dalgliesh)
  2178. Subject: VBL synching (again)
  2179. Date: 17 Jan 1996 11:18:50 GMT
  2180. Organization: Slipped Disk Software
  2181.  
  2182. This is the first of two ideas which I had for possible implementaion in games.
  2183. I don't know if they have been mentioned b4 or if they are already used, which
  2184. is why I'm asking about their feasiblity now.
  2185.  
  2186. OK, say we have a VBL routine which sets a variable (it'd just have a ptr
  2187. to it) to the current time (obviously in a resultion better than ticks -
  2188. say
  2189. microseconds). Now at init time in the game it times how long it takes for
  2190. one VBL (or 8 and divides it by 8 - whatever) to go past. When it comes
  2191. time to blit to the screen from your offscreen gworld, you get the last
  2192. VBL time, get the current time, and using the time for one beam cycle
  2193. figure out where the beam is - and start blitting just behind it (or
  2194. exactly half way away from it - whatever method stops tearing). Note that
  2195. this could easily be adapted to two copybits calls if you don't want to
  2196. write a special blitter.
  2197.  
  2198. However, the time which the beam takes to go from the bottom of the screen
  2199. back to the top must be taken into account - more importantly, does the
  2200. VBL occur when it's just reached the bottom or when it's just returned to
  2201. the top? Anyway, I would suppose that the majority of it's time is spent
  2202. actually on the screen, so this is a relatively minor issue...
  2203.  
  2204. So how about it folks? Is there anything majorly flawed with this
  2205. technique? Has it already been implemented and I've been missing out or
  2206. something :-) ?
  2207.  
  2208. TIA
  2209.  
  2210. {*^/
  2211.  
  2212. +++++++++++++++++++++++++++
  2213.  
  2214. >From rickgenter@aol.com (RickGenter)
  2215. Date: 18 Jan 1996 09:12:30 -0500
  2216. Organization: America Online, Inc. (1-800-827-6364)
  2217.  
  2218. >>>
  2219. OK, say we have a VBL routine which sets a variable (it'd just have a ptr
  2220. to it) to the current time (obviously in a resultion better than ticks -
  2221. say
  2222. microseconds).
  2223. [more details deleted]
  2224. <<<
  2225.  
  2226. The Vertical Retrace Manager is tricky to use for avoiding tearing for a
  2227. number of reasons:
  2228.  
  2229. 1) Using VInstall() won't work unless you are on an original Macintosh.
  2230. VInstall()ed tasks are run 60.15 times per second, to match the vertical
  2231. blank time on the original Macintosh.
  2232.  
  2233. 2) On a multiple monitor system, each monitor has its own vertical refresh
  2234. rate. While you can use SlotVInstall() to synchronize to each monitor, you
  2235. will have to update each monitor asynchronously with respect to the other
  2236. monitors. (Or limit your game to a single monitor.) Tearing would look
  2237. better :-).
  2238.  
  2239. 3) Unless your game already has an incredibly high frame rate (> 60 FPS),
  2240. tearing shouldn't be a priority.
  2241.  
  2242. Just MHO.
  2243.  
  2244. Rick Genter
  2245. Papyrus Design Group, Inc.
  2246.  
  2247. +++++++++++++++++++++++++++
  2248.  
  2249. >From jmunkki@beta.hut.fi (Juri Munkki)
  2250. Date: 19 Jan 1996 16:56:46 GMT
  2251. Organization: Helsinki University of Technology
  2252.  
  2253. In article <johnd-1701962224000001@dialup202.geko.net.au> johnd@geko.net.au (John Dalgliesh) writes:
  2254. >However, the time which the beam takes to go from the bottom of the screen
  2255. >back to the top must be taken into account - more importantly, does the
  2256. >VBL occur when it's just reached the bottom or when it's just returned to
  2257. >the top? Anyway, I would suppose that the majority of it's time is spent
  2258. >actually on the screen, so this is a relatively minor issue...
  2259.  
  2260. The VBL interrupt comes the moment when the video memory is no longer
  2261. being accessed, but then it goes into the interrupt handler and there
  2262. are other tasks (most notably the mouse) usually before your task.
  2263.  
  2264. I seem to remember a note saying that it is possible to insert a task
  2265. before all other tasks. This would be necessary for even remotely
  2266. accurate timing (the mouse can consume wildly varying amounts of time).
  2267. Then you are still at the mercy of other interrupts that may cause
  2268. the VBL interrupt to be delayed.
  2269.  
  2270. My opinion s that it is not worth the effort unless you are programming
  2271. for 3D shutter glasses (something I did years ago).
  2272.  
  2273. -- 
  2274. Juri Munkki jmunkki@iki.fi              Life is easy when polygons are cheap.
  2275. http://www.iki.fi/jmunkki                  Windsurfing: Faster than the wind.
  2276.  
  2277. ---------------------------
  2278.  
  2279. End of C.S.M.P. Digest
  2280. **********************
  2281.